To trigger a checkbox click event even if it’s checked with jQuery, we can call the jQuery trigger
method with 'click'
.
For instance, if we have the following HTML:
<div>
<input type="checkbox" id="item-1" value="1"> Item 1 <br />
<input type="checkbox" id="item-2" value="2" disabled> Item 2 <br />
<input type="checkbox" id="item-3" value="3" disabled> Item 3 <br />
<input type="checkbox" id="item-4" value="4" disabled> Item 4 <br />
<input type="checkbox" id="item-5" value="5"> Item 5
</div>
Then we can cal trigger
with 'click'
by writing:
$('input').trigger('click');
to click all the non-disabled checkboxes.