php - How can I close current ul and start new ul using jquery? -
please see code below: there ul span generated dynamically using php code. after 2nd span close current ul , start new ul. how can using jquery?
<ul class="menutop" id="menutop"> <span id="show_dynamic_0"> <li class="item1 active root" id="item1 active root"> <a id="a-1309599451911317" class="orphan item bullet" href="http://localhost/health_phase2/"> <span>home</span> </a> </li> </span> <span id="show_dynamic_1"> <li class="item2 root" id="item2 root"> <a id="a-1309599451912733" class="orphan item bullet" href="/health_phase2/index.php"> <span>news feed</span> </a> </li> </span> <!--here want end menutop ul. after start new ul. means end current ul , start new ul --> <!-- </ul><ul> --> <span id="show_dynamic_2"> <li class="item6 root" id="item6 root"> <a id="a-1309599451912287" class="orphan item bullet" href="/health_phase2/index.php?option=com"> <span>video</span> </a> </li> </span> <span id="show_dynamic_3"> <li class="item7 root" id="item7 root"> <a id="a-1309599451913684" class="orphan item bullet" href="/health_phase2/index.php?option=com_content"> <span>interviews</span> </a> </li> </span> </ul>
you detach elements after index > 1, wrap them in <ul> , insert them after previous <ul>:
$('#menutop > span:gt(1)').detach().wrapall('<ul />').parent().insertafter("#menutop"); example: http://jsfiddle.net/niklasvh/ewvvq/
Comments
Post a Comment