jquery appendto Usage

Source: Internet
Author: User

$ ("#top_cartWarp"). AppendTo ($ ("#top_main_right")). CSS (' position ', ' relative '). CSS (' top ', ' 0px '); return value: JQueryAppendTo(content) V1.0Overview

Appends all matching elements to another specified set of element elements.

In fact, using this method reverses the normal $ (A). Append (b) operation, that is, instead of appending B to a, append a to B.

In jquery 1.3.2,appendTo, Prependto, InsertBefore, InsertAfter, and ReplaceAll have become a destructive operation, and the return value is all of the appended content, Rather than just the previously selected element. So, to select the previously selected element, you need to use the end () method, see example Ii.

Parameters contentString

Content to be appended

Example Description:

Append all paragraphs to an element with an ID value of foo.

HTML Code:
<p>I would like to say: </p><div></div><div></div>
JQuery Code:
$("p").appendTo("div");
Results:
<div><p>I would like to say: </p></div><div><p>I would like to say: </p></div>
Describe:

New paragraph append div and add a class

HTML Code:
<div></div><div></div>
JQuery Code:
 $("<p/>")   .appendTo("div")   .addClass("test")   .end()   .addClass("test2");
Results:
<div><p class="test test2"></p></div><div><p class="test"></p></div>

jquery appendto Usage

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.