Wrap anchors in list tags in jQuery -


i have code this:

<div id="gallery">     <a href="#">link</a>     <a href="#">link</a>     <a href="#">link</a> </div> 

and want rewrite using jquery produce:

<div id="gallery">     <ul id="carousel">         <li><a href="#">link</a></li>         <li><a href="#">link</a></li>         <li><a href="#">link</a></li>     </ul> </div> 

what's best way?

example: http://jsfiddle.net/pb98t/

$('#gallery > a').wrapall('<ul id="carousel">').wrap('<li>'); 

this wraps <a> elements <ul id="carousel"> using .wrapall(), wraps them individually <li> using .wrap().


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -