Skip to content Skip to sidebar Skip to footer

Auto Sort Method To Append Function

I've dynamical list that user can add li (items) to a ul. They can choose level 1,2 and 3.. for now they all append to ul, with no sorting function. I want the level 1 always on th

Solution 1:

A method to do this will be attach attribute to li elements at specific level like:

<ul>
    <li class="level1">thisis level 1</li>
    <li class="level1">thisis level 1</li>
    <li class="level1">thisis level 1</li>
    <li class="level2">thisis level 2</li>
    <li class="level2">thisis level 2</li>
    <li class="level3">thisis level 3</li>
    <li class="level3">thisis level 3</li>
</ul>

Then do insert at appropriate level.

Check a demo: http://jsfiddle.net/Hms7Y/

Post a Comment for "Auto Sort Method To Append Function"