How to bind checkbox using Jquery?
We often use checkbox and radio button.It gives very good feel for users.It does some wonderful jobs.So here we can see how to bind the checkbox using jquery.I have given the ways of binding or checking checkboxes below.You can use either of this way as per your need.
Jquery
1.Based on the the Name of the checkbox
$('input[type=checkbox][name=test]').prop('checked', true);
2.Based on the Id of the checkbox
$('#test').prop('checked', true);
3.Based on the Class of the checkbox
$('.check').prop('checked', true);
HTML
<input type="checkbox" name="test" id="test" class="check"/>
Here I have a working example.
https://jsfiddle.net/Abeyram/pxqfbf17/18/
Jquery
1.Based on the the Name of the checkbox
$('input[type=checkbox][name=test]').prop('checked', true);
2.Based on the Id of the checkbox
$('#test').prop('checked', true);
3.Based on the Class of the checkbox
$('.check').prop('checked', true);
HTML
<input type="checkbox" name="test" id="test" class="check"/>
Here I have a working example.
https://jsfiddle.net/Abeyram/pxqfbf17/18/
Comments
Post a Comment