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 “ttr(‘checked’)” method to judge.
Several methods of jQuery to determine whether the checkbox is selected
method one:
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 }
…
The post jquery method to determine if a checkbox is checked first appeared on Lenix Blog .
This article is reprinted from https://blog.p2hp.com/archives/9191
This site is for inclusion only, and the copyright belongs to the original author.