jQuery if checkbox is checked

jQuery if checkbox is checked

回答1

for jQuery 1.6 or higher:

if ($('input.checkbox_check').prop('checked')) {
    //blah blah
}

the cross-browser-compatible way to determine if a checkbox is checked is to use the property https://api.jquery.com/prop/

评论

Note that "The .prop() method gets the property value for only the first element in the matched set." see api.jquery.com/prop 

 May 19, 2014 at 12:11

 

回答2

if ($('input.checkbox_check').is(':checked')) {

 

回答3

his $('#checkboxId').is(':checked') for verify if is checked

& this $("#checkboxId").prop('checked', true) to check

& this $("#checkboxId").prop('checked', false) to uncheck

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(68)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2021-03-09 Using AntiXss As The Default Encoder For ASP.NET
2021-03-09 What is the difference between AntiXss.HtmlEncode and HttpUtility.HtmlEncode?
2021-03-09 Should I use .done() and .fail() for new jQuery AJAX code instead of success and error
2019-03-09 Inversion of Control Containers and the Dependency Injection pattern
2019-03-09 82. Remove Duplicates from Sorted List II
2019-03-09 83. Remove Duplicates from Sorted List
2018-03-09 fixed和absolute
点击右上角即可分享
微信分享提示