Home > Web Front-end > JS Tutorial > body text

Introduction and application of jquery element control (append element/append content)_jquery

WBOY
Release: 2016-05-16 17:35:57
Original
1121 people have browsed it
1. Append elements inside/outside the element
append, prepend: added to child elements
before, after: added as sibling elements
html:
Copy code The code is as follows:


In my Append a news item




Javascript:
Copy code The code is as follows:



Add elements inside #content. This is to add

Yao Ming retired...

as a child element to #content. If you want to append elements outside the element, you need to use after. In this case You can append

Yao Ming retired...

as a brother element after #content
Copy code The code is as follows:



2. Append content at different positions of the element
html
Copy the code The code is as follows:


The bright moonlight in front of the window


>
The code is as follows:

3. At the beginning of the element Position append content

html




Copy code

The code is as follows:
< div>

Append a news after me

javascript

Copy code


The code is as follows:

4. Append content at the beginning of different elements

html




Copy code

The code is as follows:

In my Add a piece of news after

Copy code The code is as follows:


Add elements inside #content. This is to add suspected to be frost on the ground as a sub-element to the beginning of #content. If you want to add a start element outside the element, you need to use before. In this case, you can add suspected to be frost on the ground as a sibling element to #content and start
Copy code The code is as follows:



5. Contain with elements of specified structure Element
Warp(html)
specifies the html element in the specified html, but the specified element cannot contain sibling elements, otherwise it will not run normally and does not contain general text strings. The following code Use div tags to include p tags
html
Copy code The code is as follows:

< form id="form1" runat="server">
include me in div


javascript
Copy code The code is as follows:



6. Contain multiple html elements with specified elements
warpAll(html)
html
Copy code The code is as follows:


pcontent


pcontent


pcontent


pcontent


p Content




javascript
Copy code The code is as follows:



7. Use the specified tag to include sub-elements
wrapInner(html)
Same as the warp method, specify the html element in html, for example:
Use the b tag to include the text in the p tag The code is as follows:
html code

Enclose the text of the p tag with the b tag


Also include the text of the p tag with the b tag< /p>

Copy code The code is as follows:

javascript
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template