选择不在jquery中的选项值
我有一个HTML选择不在jquery中的选项值,jquery,html-select,Jquery,Html Select,我有一个HTML选择,如下所示: <select name="customer_id"> <option value="5">A1</option> <option value="7">A2</option> <option value="3">A3</option> <option value="6">A4</option> <option value="4">A5</
选择
,如下所示:
<select name="customer_id">
<option value="5">A1</option>
<option value="7">A2</option>
<option value="3">A3</option>
<option value="6">A4</option>
<option value="4">A5</option>
<option value="2">Root</option>
</select>
<button name="View" type="button" id="view" >View Commission</button>`
$("#view").click(function(){
var customer_id = $("#customer_id").val();
alert(customer_id);
});
但是我没有得到客户id
,而是得到了未定义的警告!怎么了
查看代码:$(“#客户id”).val()代码>引用ID为customer\u ID的元素,您只有一个名称
将您的选择更改为:
<select name="customer_id" id="customer_id">
$(“客户id”).val()代码>引用ID为customer\u ID的元素,您只有一个名称
将您的选择更改为:
<select name="customer_id" id="customer_id">
$(“客户id”).val()代码>引用ID为customer\u ID的元素,您只有一个名称
将您的选择更改为:
<select name="customer_id" id="customer_id">
$(“客户id”).val()代码>引用ID为customer\u ID的元素,您只有一个名称
将您的选择更改为:
<select name="customer_id" id="customer_id">
问题是您正在使用
var customer_id = $("#customer_id").val();
这里$(“#customer_id”)仅在select id为“customer_id”时有效
因此,请使用您的选择作为
select id="customer_id" name="customer_id"
如果它对您有效,它将起作用。问题是您正在使用
var customer_id = $("#customer_id").val();
这里$(“#customer_id”)仅在select id为“customer_id”时有效
因此,请使用您的选择作为
select id="customer_id" name="customer_id"
如果它对您有效,它将起作用。问题是您正在使用
var customer_id = $("#customer_id").val();
这里$(“#customer_id”)仅在select id为“customer_id”时有效
因此,请使用您的选择作为
select id="customer_id" name="customer_id"
如果它对您有效,它将起作用。问题是您正在使用
var customer_id = $("#customer_id").val();
这里$(“#customer_id”)仅在select id为“customer_id”时有效
因此,请使用您的选择作为
select id="customer_id" name="customer_id"
如果对你有用,它会起作用的。@ArunKillu:他得到了警报tho…你能用小提琴复制这个吗?哦,好吧,这不是问题,也很有趣,但不是真的相关:@ArunKillu:他得到了警报tho…你能用小提琴复制这个吗?哦,好吧,这不是问题,也很有趣,但不是真的相关:@阿伦基卢:他得到了警报…你能用小提琴复制这个吗?哦,好吧,这不是问题,也很有趣,但不是真的相关:@ArunKillu:他得到了警报…你能用小提琴复制这个吗?哦,好吧,这不是问题,也很有趣,但不是真的相关: