jQuery: selector question (parent)
Question
i'm having this markup:
<ul class=container>
<li rec=1>
<div>
<div>
<div>i'm here</div>
</div>
</div>
</li>
</ul>
now i'm at the div element ("i'm here"), how can i get reference to the li?
i tried div.parent("li");
but didntwork ..
Solution
Use
closest("li")
rather than parent http://docs.jquery.com/Traversing/closest Parent only gets the direct parent.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow