How jquery adjusts the order of LI elements

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.