javascript - Get Position and Width of Parent Menu -


i want know how parent position , width jquery. example

<ul id="menu"><li>parents</li>     <ul><li>child</li></ul> </ul> 

my jquery:

if($('#menu > li > ul').children('li').hasclass('current-menu-item')){ //do animate         left: $(this).parent().siblings().position().left;,         width: $(this).parent().siblings().width();     }); 

in case, @ <li>child</li>. how position , width of <li>parents</li>?

var parent = $('#menu .current-menu-item').parent().closest('li'); var position = parent.position(); var width = parent.width(); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -