I would like to create one of those read more / read less buttons using toggleClass().
This is my html:
<p>Lots of bla bla bla.....<span id="plus">Plus</span></p>
<p>Lots of bla bla bla.....<span id="plus">Plus</span></p>
<p>Lots of bla bla bla.....<span id="plus">Plus</span></p>
This is my jQuery:
$(function(){
$("#plus").on("click", function () {
$(this).parent().toggleClass( "showmore" );
var txt = $("p").hasClass("showmore") ? 'Minus' : 'Plus';
$("#plus").text(txt);
});
});
Fiddle: Click here
My Question:
How do I get toggleClass to work with multiple IDs (same selectors). The current script only works with the first ID.
Looking forward to your input, cheers!