<li>
<input type= "checkbox" name="paradigm" id="id_1" value="3"/>
<label for="name_3">foo</label>
</li>
<li>
<input type= "checkbox" name="paradigm" id="id_2" value="4"/>
<label for="name_4">bar</label>
</li>
这里有两个复选框。如果我选中复选框 id_1
,使用 jquery 我想读取标签 foo
。如果我检查了两者,那么它应该是 ['foo','bar']
。
最佳答案
$("input:checkbox:checked").map(function(){
return $(this).next().text();
}).get();
关于javascript - jquery中如何读取checkbox的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5561651/