glenelkins Posted December 5, 2008 Share Posted December 5, 2008 Hi I have an unordered list like this <ul> <li id="idname"><a href="">bla bla</a></li> </ul> here is my JS code...its not showing me the width of "idname"...help!! please lol // Get menu item left pos var currentEl = document.getElementById ( 'idname' ); alert ( currentEl.getAttribute( "width" ) ); Link to comment https://forums.phpfreaks.com/topic/135661-get-width-of/ Share on other sites More sharing options...
KevinM1 Posted December 5, 2008 Share Posted December 5, 2008 Hi I have an unordered list like this <ul> <li id="idname"><a href="">bla bla</a></li> </ul> here is my JS code...its not showing me the width of "idname"...help!! please lol // Get menu item left pos var currentEl = document.getElementById ( 'idname' ); alert ( currentEl.getAttribute( "width" ) ); Does your <li> have a set width? Because unless it's set, it'll just be the default width, which is slightly smaller than the width of the list's (<ul>) containing element. I doubt this attribute would have a concrete number in terms of pixels, due to the way it's generated. Link to comment https://forums.phpfreaks.com/topic/135661-get-width-of/#findComment-706916 Share on other sites More sharing options...
glenelkins Posted December 8, 2008 Author Share Posted December 8, 2008 hi the width is set in the CSS Link to comment https://forums.phpfreaks.com/topic/135661-get-width-of/#findComment-709376 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.