html - re build ul and li tag with Jquery -


i try find way split ul tag showing 10 li tag per ul.

suppose have li 30 elements. script re build 3 ul , each ul has 10 li tag.

how can ?

suppose original :

<ul id="ul1" style="">     <li><a href="#"><span>adidas</span></a></li>     <li><a href="#"><span>jason markk</span></a></li>     <li>... 28 mores </li> </ul> 

jquery re build ul in 3 ul (10 li per ul):

<ul id="ul1" style="">     <li>10 times</li> </ul> <ul id="ul2" style="">     <li>10 times</li> </ul> <ul id="ul3" style="">     <li>10 times</li> </ul> 

please guide, thanks

you can this

var n = 5; var uls = $("#ul1 li").length / n; (i = 0; < uls; i++) {     var newul = $("<ul/>", { id: "ul" + (i + 2) });     $("ul").eq(i).after(newul);     newul.append(newul.prev().find("li:gt(" + (n - 1) + ")"));  } 

change value of n according need

fiddle


Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -