Home  >  Article  >  Web Front-end  >  jquery method to determine whether checkbox is selected

jquery method to determine whether checkbox is selected

藏色散人
藏色散人Original
2020-12-03 09:23:1610555browse

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.

jquery method to determine whether checkbox is selected

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn