I am trying to do this:
- Get ID from
data-status
attribute of.addlink
and store it aspost_id
. - Clicking on
.mar-post_id
will toggle.finished-reading
from#statusfor-post_id
I have the following code but it does not work. What could I be doing wrong?
jQuery(".addlink").click(function(){
var post_id = jQuery(this).attr("data-status");
jQuery(".mar-"+post_id).click(function() {
jQuery("#statusfor-"+post_id).toggleClass( "finished-reading" );
});
});
The following is the HTML markup.
<div class="simple-card" id="statusfor-12">
<div class="simple-card-actions">
<span class="wpfp-span">
<a class="addlink mar-12" href="#" data-status="12">Click me to toggle</a>
</span>
</div>
</div>