I am curious about how to retrieve the position and width of a parent element using jQuery. To demonstrate, consider the following HTML:
<ul id="menu">
<li>Parents</li>
<ul>
<li>Child</li>
</ul>
</ul>
Here is my jQuery code snippet:
if($('#menu > li > ul').children('li').hasClass('current-menu-item')){
//perform an animation
left: $(this).parent().siblings().position().left,
width: $(this).parent().siblings().width()
});
If I am currently at <li>child</li>
, how can I obtain the position and width of its parent element <li>parents</li>
?