开发者

Jquery sort sublists with classes

I have a php script that fetches the results into lists, but the list come out with the sublists in the bottom of the ul, this script isnt mine but im trying to sort the sublist into their right place.

results are like this now:

<ul id='list'>
<li class='47'>DVD</li>
<li class='48'>Spill</li>
<li class='49'>Utst开发者_C百科yr</li>
  <ul class='sublist 49' style='display:none;'>
  <li>Dvd spillere</li>
  <li>Dvd/Blueray spillere</li>
  </ul>
 <ul class='sublist 47' style='display:none;'>
  <li>Barnefilmer</li>
  <li>Voksen filmer</li>
  </ul>
</ul>

But all with sublist 47 should be under li class 47.

Is there any way to have jquery sort out this?


I don't know how much this will help, considering that your class names aren't valid, but it's quite easy to 'reparent' an element in jQuery:

$('parent-selector').append($('child-selector'));

...so assuming you can select the sublists and their proper parents properly, this should be all you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜