0
<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.

Alex
  • 11,551
  • 13
  • 30
  • 38

2 Answers2

1
var pid = $(this).closest('ul').attr('id');
Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
1
if($(this).closest("ul").attr("id") == "productmenu"){
}
Jude Duran
  • 2,195
  • 2
  • 25
  • 41
  • Hi thx for your replay. But the structure is actuall `
      ` It is a sub menu. Seems like closet('ul') does not work here. Can I use something else instead?
      – Alex Apr 25 '13 at 11:39
    • Did you try it? it works on my side..:) closest("ul") will get the nearest "ul" elemenent upwards. – Jude Duran Apr 25 '13 at 11:52