I'm currently working on a comment and like system similar to Facebook. However, I am struggling to select the specific div element!
Here is a snippet of my current HTML:
<div class='activoptions'><a href='#'>Like</a> <a href='#' class="addcomment">Add commentr</a> <a href='#'>Share</a>
</div>
<ul class="addcommentbox">
<li class="commentlist">
<div class="CommentBox">
<div class="CommentBoxPicBox">
<a href="">
<img src="" />
</a>
</div>
<div class="CommentBoxTextBox">
<div class="CommentBoxTextBoxName">Name</div>
<div class="CommentBoxTextBoxText">Some lovely text inside a lovely div</div>
<div class="CommentBoxTextBoxTime">x minutes ago - <a href="#">Like</a>
</div>
</div>
</div>
</li>
</ul>
I have set the "CommentBox" CSS property to display:none;
so it's hidden. My jQuery code looks like this: $(".commentbox").show();
The issue lies in how the jQuery selects the correct div when a link with the ".commentadd" class is triggered. After searching online for help, I came across this code snippet.
$(".addcomment").click(function(){
var $this = $(this);
var child = $this.find('.addcommentbox').html();
$(child).show();
});
EDIT: I apologize for the lack of clarity... I will revise the explanation for better understanding. What I am trying to achieve is that when someone clicks "like," "comment," or "share," only that specific activity should be queried through Ajax and inserted into the database.