开发者

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/

jquery outerwidth submenu items


(source: jquery.com)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜