Tuesday, 27 August 2013

JQuery checkbox check

JQuery checkbox check

Suppose I have 3 checkboxes (one,two,three). Now I want that if I click
checkbox one then checkbox two and three will uncheck.
Another example: if I click checkbox two then checkbox one and three will
uncheck.
And if I click checkbox three then checkbox one and two will uncheck.
HTML
<input type="checkbox" class="check" value="one"><label>One</label>
<input type="checkbox" class="check" value="two"><label>Two</label>
<input type="checkbox" class="check" value="three"><label>Three</label>
jQuery
$(document).ready(function(){
$(".check").click(function(){
$(".check").attr("checked", "checked");
} else {
$(".check").removeAttr("checked");
});
});

No comments:

Post a Comment