Home  >  Article  >  Web Front-end  >  3 ways to determine whether a checkbox is selected with jQuery_jquery

3 ways to determine whether a checkbox is selected with jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 16:39:54909browse

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
}

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