How do I trigger a single event defined for a class of objects
- by mrbinky3000
I have a question. I have 8 buttons that have unique incrementing id's and a shared class.
<button class="btnChapter" id="btnChapter_1" value="1">1</button>
<button class="btnChapter" id="btnChapter_2" value="2">2</button>
<button class="btnChapter" id="btnChapter_3" value="3">3</button>
...
In order to prevent me from duplicating code, I bound a click event to the btnChapter class instead of binding an event individually to each button's ID.
$('.btnChapter').click(function(){ .. do stuff .. });
How do I trigger() the click() event only for #btnChapter_2? The following doesn't seem to work.
$('#btnChapter_2').click()