在一个 div 中,我有一些复选框。我想当我按下一个按钮时,选中所有复选框的所有名称。你能告诉我怎么做吗?
<div id="MyDiv">
....
<td><%= Html.CheckBox("need_" + item.Id.ToString())%></td>
...
</div>
谢谢,
最佳答案
$(document).ready(function() {
$('#someButton').click(function() {
var names = [];
$('#MyDiv input:checked').each(function() {
names.push(this.name);
});
// now names contains all of the names of checked checkboxes
// do something with it
});
});
关于javascript - 使用 jQuery 获取复选框列表值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1287592/