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
Post a Comment