About the difference between append,appendto,prepend,prependto

Source: Internet
Author: User

Before doing the project for these several methods are always a little vague, especially prepend and prependto;

1.append

<style>    span{        background:yellow;    }    . test{        background: #ccc;        height:50px;    }      . test_1{        background:red;    }     </style><body>    <div class= "test" ><span class= "test_1" > I'm standing right here </span></div ></body><script>    $ ('. Test '). Append ("<span> I am testing fast </span>"); </script>

The append is the inside of the insert element behind

2.appendTo

$ (' <span> I am testing fast </span> '). AppendTo ($ ('. test '));

And the same effect as above, is to change the wording

3.prepend

$ ('. Test '). Prepend ("<span> I am testing fast </span>");

This method contrasts with the append.

Append is the inside of the inserted element, and prepend is the first inside of the inserted element.

4.prependTo

$ (' <span> I am testing fast </span> '). Prependto ($ ('. test '));

The effect above is the same as in prepend

About the difference between append,appendto,prepend,prependto

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.