Use the append, prepend, before, and after methods in jquery, and use jqueryprepend.

Source: Internet
Author: User

Use the append, prepend, before, and after methods in jquery, and use jqueryprepend.

I. Differences between the after () and before () Methods

After () -- The method is to add parameters in the method to the end of the jquery object;
For example, A. after (B) means to put B behind;

Before () -- The method is to add parameters in the method to the front of the jquery object.
For example, A. before (B) means placing A before B;
 
Ii. Differences between insertAfter () and insertBefore () Methods
In fact, it is to adjust the position of the element;

It can be an existing element on the page or an element dynamically added.

For example: A. insertAfter (B); that is, Transfer Element A to the end of element B;
For example, <span> CC </span> <p> HELLO </p> uses $ ("span "). after insertAfter ($ ("p"), it becomes <p> HELLO </p> <span> CC </span>. The positions are changed.
 
Iii. Differences between append () and appendTo () Methods

Append () -- The method is to add parameters in the method to the jquery object;
For example, A. append (B) means to put B in A, append it to the end, and the last position of the child element of;

AppendTo () -- The method is to add the jquery object to the parameter specified by appendTo.
For example, A. appendTo (B) means to put A in B, append it to the end, and the last position of the child element of B;
 
Iv. Differences between prepend () and prependTo () Methods

Append () -- The method is to add parameters in the method to the jquery object;
For example, A. append (B) means to put B in A and insert it to the first position of the child element of;

AppendTo () -- The method is to add the jquery object to the parameter specified by appendTo.
For example, A. appendTo (B) means to put A into B and insert it to the first position of the child element of B;

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.