jquery outerwidth submenu items
i'm looking for a way to calculate the total width of de level 2 items and put it in the ul. I have looked at some jquery thinks like outerWidth and .lengt but can't figure it out.
thanks in advance
$('#menu li:has(ul) ul').each(function()
开发者_开发问答<ul>
<li>level 1</li>
<li>
<ul style="widht:??;">
<li>level 2</li>
<li>level 2</li>
</ul>
</li>
<li>level 1</li>
</ul>
The width()
method of jQuery will give you the calculated width of an element:
$(function(){
$('#menu li:has("ul")').each(function(){
alert($(this).width());
});
});
Get the current computed width for the first element in the set of matched elements.
http://api.jquery.com/width/
(source: jquery.com)
精彩评论