jquery Basics: The difference between append, prepend, after, before, Appendto

Source: Internet
Author: User

Append () is the selected element in theEnd Tag Front(that is, the interior of the selected element) inserts the specified content. After () is in the selected element'send tag behind(That is, the outside of the selected element) to insert the specified content. AppendTo ()is stillIn the selected element'sEnd Tag Front(that is, the interior of the selected element) to insert the specified content,It's just that the jquery function doesn't have the same wording.。 The difference between pretend () and before () is the same as the difference between append () and after (), slightly.

Source code used for analysis:

<!DOCTYPE HTML><HTML><HeadLang= "en">    <MetaCharSet= "UTF-8">    <title></title>    <Scriptsrc= "Http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></Script>    <Scripttype= "Text/javascript">$ (). Ready (function(){            $("#button1"). Click (function(){                $("span"). Append ('<a href= "#" >append method </a>'); })            $("#button2"). Click (function(){                $("span"). After ('<a href= "#" >after method </a>'); })            $("#button3"). Click (function(){; $('<a href= "#" >appendto method </a>'). AppendTo ("span"); })        })    </Script></Head><Body>        <span>The differences between the Append, after, AppendTo, pretend, before methods of jquery</span>        <ButtonID= "Button1">Append</Button>        <ButtonID= "Button2">After</Button>        <ButtonID= "Button3">AppendTo</Button>        <P>To see the difference, please F12 to see the source, right-click No</P></Body></HTML>

jquery Basics: The difference between append, prepend, after, before, 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.