How to use jquery to insert a new LI element behind any of the specified LI elements

Source: Internet
Author: User

How to use jquery to insert a new LI element after any of the specified LI elements:
This section describes how to use the jquery implementation to insert a new LI element behind any Li element.
Native JavaScript can use the InsertBefore () function, which can be found in the InsertBefore, InsertAfter, and AppendChild sections of JavaScript .
Here's how to implement this with jquery.
code example:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>Ant Tribe</title><styletype= "Text/css">ul Li{Height:25px;List-style:None;font-size:12px;}</style><Scriptsrc= "Http://libs.baidu.com/jquery/1.9.0/jquery.js"></Script><Scripttype= "Text/javascript">$ (document). Ready (function(){  $("#bt"). Click (function(){    $("#box Li"). EQ (1). After ("The spirit of <li> sharing and the bosom of mutual help are the most important source of progress. </li>"); $( This). Prop ("Disabled",true); })})</Script> </Head> <Body> <ulID= "box">  <Li>Ant Tribe welcomes You</Li>  <Li>Provides a rich div CSS tutorial content.</Li>  <Li>Only hard work will have a good future.</Li></ul><inputtype= "button"ID= "BT"value= "View Effect"/></Body> </HTML>

The above code implements our requirements by clicking the button to add a new LI element to the back of the second Li element.
Related reading:
The 1.eq () function can be found in the section on the EQ () method of jquery .
The 2.after () function can be found in the After () method section of jquery .
The 3.prop () function can be found in the prop () method section of jquery .

The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=15190

For more information, refer to: http://www.softwhy.com/jquery/

How to use jquery to insert a new LI element behind any of the specified 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.