How jquery adjusts the order of the LI elements:
In practical applications, you may need to adjust the relative order of the LI elements, such as inserting an LI element behind or in front of another Li element, and using the example code to describe how to do this with jquery, the code example is as follows:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>Ant Tribe</title><Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script><Scripttype= "Text/javascript"> $(function(){ $("ul Li:eq (2)"). InsertAfter ("ul Li:eq (4)"); }); </Script></Head><Body><ul> <Li>Ant Tribe One</Li> <Li>Ant Tribe II</Li> <Li>Ant Tribe Three</Li> <Li>Ant Tribe Four</Li> <Li>Ant Tribe Five</Li> <Li>Ant Tribe VI</Li></ul></Body></HTML>
The above code can move the third Li element behind the fifth Li element, where it is moved, not copied.
Related reading:
1.eq () selector See jquery's: eq () selector section.
The 2.insertAfter () function can be found in the InsertAfter () method section of jquery .
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=11666
For more information, refer to: http://www.softwhy.com/jquery/
How jquery adjusts the order of LI elements