Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does jquery determine whether the check box is selected?

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 207

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report