Alex
Alex

Reputation: 12171

how to check parent's parent's id equals

<ul id="productmenu">
    <li>
      <a ref="#"></a>
    </li>
</ul>

how to check if a link's parent's parent has got an id = "productmenu"? I tried with PrentNode, but it did not work.

Upvotes: 0

Views: 1133

Answers (2)

Adil Shaikh
Adil Shaikh

Reputation: 44740

var pid = $(this).closest('ul').attr('id');

Upvotes: 1

Jude Duran
Jude Duran

Reputation: 2205

if($(this).closest("ul").attr("id") == "productmenu"){
}

Upvotes: 1

Related Questions