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

silverlight - Applying a style to ItemContainerStyle in C# -

c# - NullReferenceException in MySqlClient.NativeDriver -

php - Updating recent updates - Problem in procedure - Any other approach? -