im trying to get this button to show a hidden div onClick
within each li that will show over the post div in an absolute positioning. The problem is, on click, it's showing all of the hidden div's for all li's. Im using wordpress + buddypress, so each li's id has a unique ID
<li id="activity-<?php bp_activity_id(); ?>" class="activity" >
<div id="post"></div>
<div class="action">
//my pop in stuff
</div>
<div id="post-actions-bar">
<button id="show">show</button>
</div>
</li>
and here's my jquery that I thought would work.
NOTE: I'm using .on()
because there will be li's added dynamically.
$(document).on( 'click' , '.activity button#show' , function() {
$('.action').show();
});
In a sense it does work, but it shows all of the .action div's
for every li on the screen, I only want to show the one for that li's button that was clicked. I tried using .each()
but It's not working. I'm ding something wrong (obviously lol)
Any ideas?
See Question&Answers more detail:os