jquery document Processing

Source: Internet
Author: User

Document processing: Append (), Appendto (), prepend (), after (), before (), Clone ():
Append is the addition of the content inside the element, within the element, after the content,

The appendto is to append the existing content to the element, after the element, the content, and the HTML to replace all of the current content.


Append (): Method inserts the specified content at the end of the selected element (still inside), example:

var html = "<div id= ' test ' title= ' Hi ' >1234567</div>"
$ ("#diva"). Append (HTML);
<div id= ' test ' ><div id= ' test ' title= ' Hi ' >1234567</div></div>

Appendto (): content appended to an element, example:
<p>eat chicken</p>
$ ("P"). AppendTo ("div");
<div><p>eat Chicken: </p></div>

Prepend (): Appends some elements to an element, as an example:
$ ("P"). Prepend ("<b>Hello</b>");
<p><b>hello</b>eat chicken</p>

After (): Append element after element, example:
$ ("P"). After ("<b>Hello</b>");
<p>eat Chicken: </p><b>Hello</b>

Before (): Insert element before element, example:
$ ("P"). Before ("<b>Hello</b>");
<b>hello</b><p>eat Chicken: </p>

Wrap the element with a newly created element, for example:
$ ("P"). Wrap ("<div class= ' wrap ' ></div>")
<div class= ' Wrap ' ><p></p></div>

Empty (): The child elements of all elements (including text nodes) are deleted, examples:
<p>hello, <span>Person</span> <a href= "#" >and person</a></p>
$ ("P"). empty ();
<p></p>

Clone (): Clones an element and prepend to an element:
$ ("B"). Clone (). Prependto ("P");
<p><b></b>eat chicken</p>

jquery document Processing

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.