The difference between three functions of jquery after append appendto

Source: Internet
Author: User

the description of the JQ documentation is1, after function definition and usage: the After () method inserts the specified content after the selected element. Syntax: $ (selector). After (content) instance:"Text/javascript"Src="/jquery/jquery.js"></script><script type="Text/javascript">$ (). Ready (function () {$ ("Button"). Click (function () {$ ("span"). After ("<a href="#">ddddd</a>")  })})</script>The results are as follows:<span>aaaaaaaaaaaaaaa</span><a href="#">ddddd</a>the span tag has one more a tag behind it.2, append function definition and usage: the Append () method inserts the specified content at the end of the selected element (still inside). Syntax: $ (selector). Append (content) instance:"Text/javascript"Src="/jquery/jquery.js"></script><script type="Text/javascript">$ (). Ready (function () {$ ("Button"). Click (function () {$ ("span"). Append ("<a href="#">ddddd</a>")  })})</script>The results are as follows:<span>aaaaaaaaaaaaaaa<a href="#">ddddd</a></span>more than one a tag inside the span tag3, AppendTo function definition and usage: the AppendTo () method inserts the specified content at the end of the selected element (still inside). Syntax: $ (content). AppendTo (Selector) Example:"Text/javascript"Src="/jquery/jquery.js"></script><script type="Text/javascript">$ (). Ready (function () {$ ("Button"). Click (function () {//$ ("span"). AppendTo ("<a href=" # ">ddddd</a>"), so the wording is incorrect$("<a href="#">ddddd</a>"). AppendTo ("span")  })})</script>The results are as follows:<span>aaaaaaaaaaaaaaa<a href="#">ddddd</a></span>the span tag has one more a-label effect and the Append function is the same, except that they are written in reverse. Note: The Before function is the opposite of the after function, which means that the element is preceded by the specified element



The difference between three functions of jquery after append appendto

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.