I’m trying to add “delete comment” functionality to my website, but there is a problem. When I click trigger (three dots), all of the delete buttons appear on all comments that are listed. I want it to be appear on the comment that’s clicked.
$('.comment-delete').click(function (a) {
a.preventDefault();
$(this).css('display', 'block'); // this one adds display:block to span, but I want to target its child anchor.
});
jQuery(document).ready(function ($) {
$('.comment-delete').click(function (a) {
a.preventDefault();
var thisId = $(this).attr('id');
$('#a'+thisId).css('display', 'block'); // this one adds display:block to span, but I want to target its child anchor.
});
})
The trick here is to add an “a” to the beginning of the child ID.
you could also do