jayant rawat jayant rawat - 1 year ago 53
jQuery Question

How to find parent id by click on child id and then child id by getting parent id via jquery

I am creating commenting module on product page in which i am showing option of spam comment and there i am showing onclick show and hide popup. now it is working fine in single comment but when comment is two it opens both on one time because the class is same. Now that's why i want to get the parent li id so we can find only the internal class of that id not the another one

Here is my jsfiddle link

this is my script

$(".slidermenudown .fa-angle-down").on("click",function(){





Answer Source

Try this , I have modified your fiddle itself and your css also.



    $(".slidermenudown .fa-angle-down").on("click", function() {

  var $this = $(this).parents('.comment'); // "this" is the click's target. 
  var $anthr = $this.find(".anthr_usr_cmnt");
  var $owner = $this.find(".owner_cmnt");

  if ($anthr.hasClass("active")) {
  } else {
    if ($owner.hasClass("active")) {