我正在使用jQuery,我发现在另一篇文章中,计数复选框被选中。Jquery count复选框并覆盖css
jQuery的
$(document).ready(function() {
$("input[type=checkbox]").each(function() {
$(this).change(updateCount);
});
updateCount();
function updateCount() {
var count = $("input[type=checkbox]:checked").size();
$("#count").text(count);
$("#statusCount").toggle(count > 0);
}
});
HTML
<div id="statusCount" class="text-center mbm">
<span id="count">0</span><br/>
<span class="featurecounter">Plans Selected</span>
</div>
我的问题:
我需要在jQuery的做实现以下目标:
- 检查当前计数> 4
- 如果1为真变化
.statusCount {background-color:red}
基本上,如果用户选择了不止,背景变为红色。
你不应该使用大小()HTTP: //api.jquery.com/size/ –
只是一个问题 - 你知道当前的updateCount()是做什么的吗? –
注意到..谢谢A.沃尔夫 –