I got this code for a project. When i click on #showbutton i want all comments to slideout. which for one element its not that hard to do. im using this code for that:
(this is a comment section inside a post)
<button id="show">Show comments</button>
<div class="comments2" id="comments">
<p><b>person</b>: comment comment comment </p>
<p><b>person</b>: comment comment</p>
<p><b>person</b>: comment comment</p>
<p><b>person</b>: comment comment</p>
</div>
<button id="close">Close comments</button>
$( document ).ready(function() {
$("#comments").hide();
$("#close").hide();
$("#show").click(function() {
$("#show").hide();
$("#comments").slideDown(1000);
$("#closebutton").slideDown(1100);
});
$("#close").click(function() {
$("#comments").hide();
$("#close").hide();
$("#show").show();
});
});
But now i have the problem, there are more posts with comments. And every post can slide out its own comments. And if i click one button all the comments from only one post will slide out and the rest wont work. How can i make this code that for every button it can slide out its own comments