Ignacio Correia
Ignacio Correia

Reputation: 3668

Add a DIV arround each UL(sub-menu) - Drop down menu

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

Upvotes: 0

Views: 218

Answers (2)

palaѕн
palaѕн

Reputation: 73896

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

Upvotes: 1

Samuel Caillerie
Samuel Caillerie

Reputation: 8275

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.

Upvotes: 2

Related Questions