Document processing of the work-jquery in the Week Four (part)

Source: Internet
Author: User

Some simple tests, tools sublime text, Firebug

Append appends content to each matching element.

eg

<PID= ' P1 '>Text</P><Scripttype= "Text/javascript">  vartext=""    $(function(){        $("#p1"). Append ($ (text)); });</Script>

after performing the above after the code, the Firebug in-memory tag information becomes

<id= "P1"> text <H2> This is a H2 </ H2 > </ P >

The Append function in jquery is to insert text into the specified label.

AppendTo: Appends all matching elements to another specified set of element elements

<PID= ' P2 '>Text</P>    <H2>A</H2>     <H2>B</H2><Scripttype= "Text/javascript">    $(function(){        $("#p2"). AppendTo ($ ("H2")); });</Script>

in the page The display effect code is as follows

<H2>a<PID= "P2">Text</P></H2><H2>b<PID= "P2">Text</P></H2>

contrary to append, Appendto is to cut and copy the original label into the specified label .

Prepend: Front content to each matched element.

<PID= ' P3 '>Text</P><H3>A</H3><H3>B</H3><Scripttype= "Text/javascript">    $(function(){        $("#p3"). Prepend ($ ("H3")); });</Script>

page Effects

<id= "P3"><h3>a</ H3 > < H3 >b</h3> text </p> 

got the same results as append.

Prependto: puts all matching elements in front of another, specified set of element elements.

<PID= ' P4 '>Text</P><H1>A</H1><H1>B</H1><Scripttype= "Text/javascript">    $(function(){        $("#p4"). Prependto ($ ("H1")); });</Script>

page effect

<H1><PID= "P4">Text</P>a</H1><H1><PID= "P4">Text</P>b</H1>

The same effect as Appendto

After: Inserts the content after each matching element.

<PID= ' P5 '>Text</P><Scripttype= "Text/javascript">    $(function(){        $("#p5"). After ($ ("")); });</Script>

Test results

<id= "P5"> text </p>< H2 > This is an after test </h2>

After is appended to the label body, there is no content intersection of the original label

Before: Insert content before each matching element

<PID= ' P6 '>Text</P><Scripttype= "Text/javascript">    $(function(){        $("#p6"). Before ($ ("")); });</Script>

Page effects

<id= "P5"> text </p>< H2 > This is a before test </h2>

Before before inserting to label

Document processing of the work-jquery in the Week Four (part)

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.