我很难找到解决这个问题的方法。我有很多复选框,我想知道其中有多少被选中。每次选中/取消选中一个框时,该值都需要更新。
到目前为止我所拥有的:
http://jsfiddle.net/drhmorw5/3/
到目前为止我的代码:
function selected() {
var i = 0;
$("#names").each(function () {
if ($(this).prop("checked") === true) {
i++;
$("#checked").text("Sum Checked: " + i);
}
})
};
$("#checked").text("Sum Checked: ");