RPM: The difference between the JQ function after, append, appendto

Source: Internet
Author: User

1. After function
Definition and Usage:
The After () method inserts the specified content after the selected element. Reference: http://keleyi.com/a/bjac/cfyxd60g.htm

Grammar:
$ (selector). After (content)

Instance Effect experience: http://keleyi.com/keleyi/phtml/jquery/13.htm

Instance code:

<HTML><Head><title>The After function instance of jquery-Ke Keeper</title><BaseTarget= "_blank" /><Scripttype= "Text/javascript"src= "Http://keleyi.com/keleyi/pmedia/jquery/jquery-1.10.2.min.js"></Script><style>. yuanlai_keleyi_com{Border:1px solid Black;padding:5px}. a_keleyi_com{Color:Blue;}a{Color:Blue}</style></Head><Body><BR/><spanclass= "Yuanlai_keleyi_com">Collayi, this is the content of span, keleyi.com.<ahref= "Http://keleyi.com/a/bjac/2oncd079.htm">Original</a></span><BR/><BR/><ButtonID= "After_keleyi_com">After function</Button><BR/><BR/><ahref= "Http://keleyi.com/keleyi/phtml/jquery/13a.htm">Append function</a> <ahref= "Http://keleyi.com/keleyi/phtml/jquery/13b.htm">Appendto function</a><Scripttype= "Text/javascript">$("#after_ke"+"leyi_com"). Click (function () {$("span"). After ('<a href= "Http://keley'+'i.com "class=" A_kel'+'eyi_com "> This is the after function plus go to the content </a>')})</Script></Body></HTML>

The results are as follows:

<span class= "yuanlai_keleyi_com" > Collayi, this is the content of span, keleyi.com. <a href= "http://keleyi.com/a/bjac/2oncd079.htm" > Original </a></span><a href= "http://keleyi.com" class= "A_keleyi_com" > This is the after function plus go to the content </a>

That is, the span tag has more than one a label behind it.

2. Append function

Definition and Usage:
The Append () method inserts the specified content at the end of the selected element (still inside). Reference: http://keleyi.com/a/bjac/0vpch15n.htm

Grammar:
$ (selector). Append (content)

Instance Effect experience: http://keleyi.com/keleyi/phtml/jquery/13a.htm

Instance code:

<HTML><Head><title>The Append function instance of jquery-Ke Keeper</title><BaseTarget= "_blank" /><Scripttype= "Text/javascript"src= "Http://keleyi.com/keleyi/pmedia/jquery/jquery-1.10.2.min.js"></Script><style>. yuanlai_keleyi_com{Border:1px solid Black;padding:5px}. a_keleyi_com{Color:Blue;}a{Color:Blue}</style></Head><Body><BR/><spanclass= "Yuanlai_keleyi_com">Collayi, this is the content of span, keleyi.com.<ahref= "Http://keleyi.com/a/bjac/2oncd079.htm">Original</a>。</span><BR/><BR/><ButtonID= "After_keleyi_com">Append function</Button><BR/><BR/><ahref= "Http://keleyi.com/keleyi/phtml/jquery/13.htm">After function</a> <ahref= "Http://keleyi.com/keleyi/phtml/jquery/13b.htm">Appendto function</a><Scripttype= "Text/javascript">$("#after_ke" + "leyi_com"). Click (function () {$(". Yuanlai_ke"+"leyi_com"). Append ('<a href= "Http://keley' + 'i.com "class=" A_kel' + 'eyi_com "> This is the Append function plus go to the content </a>')})</Script></Body></HTML>

The results are as follows:

<span class= "yuanlai_keleyi_com" > Collayi, this is the content of span, keleyi.com. <a href= "http://keleyi.com/a/bjac/2oncd079.htm" > Original </a><a href= "http://keleyi.com" class= "A_keleyi_ Com "> This is the after function plus go to the content </a></span>

That is, the span tag has one more a tag inside it.

3. Appendto function
Definition and Usage:
The AppendTo () method inserts the specified content at the end of the selected element (still inside). Reference: http://keleyi.com/a/bjac/opnw2awa.htm

Grammar:
$ (content). AppendTo (selector)

Instance Effect experience: http://keleyi.com/keleyi/phtml/jquery/13b.htm

Instance code:

<HTML><Head><title>The Appendto function instance of jquery-Ke Keeper</title><BaseTarget= "_blank" /><Scripttype= "Text/javascript"src= "Http://keleyi.com/keleyi/pmedia/jquery/jquery-1.10.2.min.js"></Script><style>. yuanlai_keleyi_com{Border:1px solid Black;padding:5px}a{Color:Blue}. a_keleyi_com{Color:Blue;}</style></Head><Body><BR/><spanclass= "Yuanlai_keleyi_com">Collayi, this is the content of span, keleyi.com.<ahref= "Http://keleyi.com/a/bjac/2oncd079.htm">Original</a>。</span><BR/><BR/><ButtonID= "After_keleyi_com">Appendto function</Button><BR/><BR/><ahref= "Http://keleyi.com/keleyi/phtml/jquery/13a.htm">Append function</a> <ahref= "Http://keleyi.com/keleyi/phtml/jquery/13.htm">After function</a> <Scripttype= "Text/javascript">$("#after_ke" + "leyi_com"). Click (function () {$('<a href= "Http://keley' + 'i.com "class=" A_kel' + 'eyi_com "> This is the Appendto function plus go to the content </a>'). AppendTo (". Yuanlai_k" + "eleyi_com")//the notation is incorrect: $ (". Yuanlai_k" + "eleyi_com"). AppendTo (' <a href= ' Http://keley ' + ' i.com ' class= ' a_kel ' + ' eyi_com ' > This is the Appendto function plus go to the content </a> ')})</Script></Body></HTML>

The results are as follows:

<span class= "yuanlai_keleyi_com" > Collayi, this is the content of span, keleyi.com. <a href= "http://keleyi.com/a/bjac/2oncd079.htm" > Original </a><a href= "http://keleyi.com" class= "A_keleyi_ Com "> This is the after function plus go to the content </a></span>

That is, the span tag has one more a tag inside it.

The effect is the same as the APPEND function, except that they are written in the opposite way.

A practical application of the Appendto function: http://keleyi.com/a/bjac/jp71q5jt.htm

Original: http://keleyi.com/a/bjac/2oncd079.htm

Related Article

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.