Home >Web Front-end >JS Tutorial >jquery method to determine whether checkbox is selected
Method: 1. Get the checkbox element, and then use the "get(0).checked)" method to judge; 2. Get the element, and then use the "is(':checked')" method to judge; 3 , get the element, and then use the "ttr('checked')" method to judge.
The operating environment of this tutorial: Windows 7 system, jquery version 1.10.0, Dell G3 computer.
Recommendation: "jquery video tutorial"
jQuery several methods to determine whether the checkbox is selected
Method 1:
if ($("#checkbox-id")get(0).checked) { // do something }
Method Two:
if($('#checkbox-id').is(':checked')) { // do something }
Method Three:
if ($('#checkbox-id').attr('checked')) { // do something }
For more programming-related knowledge, please visit: Programming Teaching! !
The above is the detailed content of jquery method to determine whether checkbox is selected. For more information, please follow other related articles on the PHP Chinese website!