Jump to content

get width of <li>


glenelkins

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.