Reputation: 199
I need to show a div if two or more checkboxes are checked using JQuery only.
How can I achieve this?
Upvotes: 0
Views: 815
Reputation: 44939
jQuery:
$('input[type=checkbox]').change(function(){
if($('input:checked').size() > 1){
$("div").show();
}
else {
$('div').hide()
}
})
HTML:
<input type="checkbox" id="one"></input>
<input type="checkbox" id="one"></input>
<input type="checkbox" id="one"></input>
<div style="display: none;">At least 2 are checked</div>
Upvotes: 2