How does jquery determine whether the check box is selected?
This article mainly explains "jquery how to determine whether the check box is selected", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "jquery how to determine whether the check box is selected" bar!
Judgment method: 1, the use of "$(check box element). Prop ('checked')" statement, if you return true is selected, return false is not selected; 2, the use of "$(check box element) .is (': checked')" statement, if you return true is selected, return false is not selected.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Jquery determines whether the check box is selected
Method 1: using prop ('checked')
Check if true is returned, and uncheck if false is returned
$(document) .ready (function () {$("button") .click (function () {var isChecked = $('# cbx'). Prop ('checked'); alert (isChecked);}) Click me to determine whether the check box is selected
Method 2: using is (': checked')
Check if true is returned, and uncheck if false is returned
$(document) .ready (function () {$("button") .click (function () {var isChecked = $('# cbx'). Is (': checked'); alert (isChecked);}) Click me to determine whether the check box is selected
Thank you for your reading, the above is the content of "jquery how to judge whether the check box is selected". After the study of this article, I believe you have a deeper understanding of how jquery determines whether the check box is selected or not. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!