jquery method to determine whether checkbox is selected

藏色散人
Release: 2021-01-07 18:04:38
Original
10483 people have browsed it

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 }
Copy after login

Method Two:

if($('#checkbox-id').is(':checked')) { // do something }
Copy after login

Method Three:

if ($('#checkbox-id').attr('checked')) { // do something }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!