I'm currently in the process of coding a comments system that involves adding reply functionality to each comment. The goal is to have a div appear under the comment when the reply icon is clicked.
Adding comments is functioning as expected:
<script>
$("#submitComment").click(function() {
var comment = $("#commentsInput").val();
if ("<%= user.profilePic %>" == "undefined" || "<%= user.profilePic %>" == "null" || "<%= user.profilePic %>" == "") {
$("#commentsBox").prepend("<div class='fullComment'><div class='userCommentBox'><div class='commentUsername'><%= user.username %></div><img class='userPic' src='../../../public/assets/miniProfilePic.png' /></div><div class='comment'>"+comment+"</div><img class='replyIcon' src='./../../public/assets/replyIcon.png'></div>");
} else {
$("#commentsBox").prepend("<div class='fullComment'><div class='userCommentBox'><div class='commentUsername'><%= user.username %></div><img class='userPic' src='https://storage.googleapis.com/gaminghub-upload/<%= user.profilePic %>' /></div><div class='comment'>"+comment+"</div><div><img class='cross' src='./../../public/assets/cross.png'><img class='replyIcon' src='./../../public/assets/replyIcon.png'></div></div>");
}
})
However, I'm facing an issue with adding a reply underneath the correct div:
$(".replyIcon").click(function () {
("<div>dfksjflsakdjfé</div>").insertAfter($(this).parent());
})
</script>
Currently, clicking on the reply icon doesn't trigger any action. My objective is to display another text area input right below the specific comment and slightly offset it for better thread visibility.
How can I successfully insert a div under the div where the reply icon was clicked?