0

this may be simple for some of you so, here it goes. I need to wrap a div arround each ul-submenu:

<div class="this-is-a-div-arround"></div>

This would be the result:

<ul>
   <li><a>1st level </a>
       <ul><li><a>2nd level</a></li></ul> ** -- add div here
   </li>
</ul>

And change the javascript to keep the menu to work of course. Link: http://j.mp/XJjPfB

2 Answers 2

2

Just use this code:

$("ul ul").wrap("<div class='this-is-a-div-arround'/>");

$("ul ul") find all nested ul and wrap add the element around these found ul.

1
  • I knew that but I wasn't specting for the drop down to work. Nice one! Props to you. Dec 10, 2012 at 14:32
1
$('ul').find('ul').wrap('<div class="this-is-a-div-arround"></div>');​​

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.