Check if checkbox is checked with jQuery

后端 未结 23 3065
忘了有多久
忘了有多久 2020-11-21 23:12

How can I check if a checkbox in a checkbox array is checked using the id of the checkbox array?

I am using the following code, but it always returns the count of ch

23条回答
  •  既然无缘
    2020-11-21 23:56

    All following methods are useful:

    $('#checkbox').is(":checked")
    
    $('#checkbox').prop('checked')
    
    $('#checkbox')[0].checked
    
    $('#checkbox').get(0).checked
    

    It is recommended that DOMelement or inline "this.checked" should be avoided instead jQuery on method should be used event listener.

提交回复
热议问题