Home > Web Front-end > JS Tutorial > body text

3 ways to determine whether a checkbox is selected with jQuery_jquery

WBOY
Release: 2016-05-16 16:39:54
Original
927 people have browsed it

The methods provided by most articles on the Internet are ineffective and can kill individuals. The method in this article has been personally tested by the editor and is effective. It is recommended to use method two:

Method 1:
if ($("#checkbox-id")get(0).checked) {
// do something
}

Method 2:
if($('#checkbox-id').is(':checked')) {
// do something
}

Method 3:
if ($('#checkbox-id').attr('checked')) {
// do something
}

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 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!