JavaScript Answers

How to Trigger a Checkbox Click Event Even if it’s Checked with jQuery?

Spread the love

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:

  <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  

Then we can cal trigger with 'click' by writing:


to click all the non-disabled checkboxes.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.