$('.choose').each(function(){
getval.push($(this).val());
for(i=0;i<=getval.length;i++){
console.log(getval[i]);
}
答案 0 :(得分:0)
选择元素通常具有两个您要访问的值。首先是要发送到服务器的值,这很容易:
$( "#myselect" ).val();
// => 1
第二个是select的文本值。例如,使用以下选择框:
<select id="myselect">
<option value="1">Mr</option>
<option value="2">Mrs</option>
<option value="3">Ms</option>
<option value="4">Dr</option>
<option value="5">Prof</option>
</select>
如果您想要获得字符串“Mr”,如果选择了第一个选项(而不仅仅是“1”),您将按以下方式执行此操作:
$( "#myselect option:selected" ).text();
// => "Mr"
答案 1 :(得分:0)
简单:
$('.choose').change(function(){
var value = $(this).val(); // You can use the variable value wherever you want
});
$(this).val() will give you the value of the select box which are changing even if there
是1000s pf具有相同类别的选择框。