Today we will see how can we check which checkbox is checked in html using jquery
If i have group of checkbox of 3checkbox then how will I know which checkbox is checked.
Code:
HTML
<html>
<body>
<input name="sheeping1" class="add" id="ship" type="radio" checked="checked">
<input name="sheeping1" class="add" id="bill" type="radio">
</body>
</html>
Jquery:
$(".add").change(function () {
if ($('.add:checked').length > 0) {
var Id = $(this).attr('id');
alert(Id);
}
});
Give class to each radio button named 'add'
then apply jquery.
If i have group of checkbox of 3checkbox then how will I know which checkbox is checked.
Code:
HTML
<html>
<body>
<input name="sheeping1" class="add" id="ship" type="radio" checked="checked">
<input name="sheeping1" class="add" id="bill" type="radio">
</body>
</html>
Jquery:
$(".add").change(function () {
if ($('.add:checked').length > 0) {
var Id = $(this).attr('id');
alert(Id);
}
});
Give class to each radio button named 'add'
then apply jquery.