PHP tutorials,a way to getting some thing new in web

Followers

Powered by Blogger.

Tuesday 24 February 2015

How to get which checkbox is checked using jquery

No comments :
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.

No comments :

Post a Comment