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

 

posted @ 2022-03-09 11:45  ChuckLu  阅读(73)  评论(0)    收藏  举报