Juqery five-document processing insert _ jquery

Source: Internet
Author: User
This operation is similar to executing the appendChild method on the specified elements and adding them to the document. Append (content)
Append content to each matching element.
This operation is similar to executing the appendChild method on the specified elements and adding them to the document.
--------------------------------------------------------------------------------
Append content to the inside of every matched element.
This operation is similar to doing an appendChild to all the specified elements, adding them into the document.
Return Value
JQuery
Parameters
Content (String, Element, jQuery): C: content to be appended to the target
Example
Append some HTML tags to all paragraphs.
HTML code:

I wowould like to say:


JQuery code:
$ ("P"). append (" Hello");
Result:
[

I wowould like to say:Hello

]
-
Certificate --------------------------------------------------------------------------------------------------------------------------------------------------
AppendTo (content)
Append all matched elements to another specified element set.
In fact, this method is used to reverse the conventional $ (A). append (B) operation, that is, not to append B to A, but to append A to B.
--------------------------------------------------------------------------------
Append all of the matched elements to another, specified, set of elements.
This operation is, essential, the reverse of doing a regular $ (A). append (B), in that instead of appending B to A, you're appending A to B.
Return Value
JQuery
Parameters
Content (String): Used to Append content
Example
Append all paragraphs to the element with the ID value foo.
HTML code:

I wowould like to say:


JQuery code:
$ ("P"). appendTo ("# foo ");
Result:

I wowould like to say:


Certificate --------------------------------------------------------------------------------------------------------------------------------------------------
Prepend (content)
Forward content to each matching element.
This is the best way to insert content to the beginning of all matching elements.
--------------------------------------------------------------------------------
Prepend content to the inside of every matched element.
This operation is the best way to insert elements inside, at the beginning, of all matched elements.
Return Value
JQuery
Parameters
Content (String, Element, jQuery): content to be inserted into the internal front-end of the target Element
Example
Add some HTML code to all sections.
HTML code:

I wowould like to say:


JQuery code:
$ ("P"). prepend (" Hello");
Result:
[ Hello

I wowould like to say:

]
--------------------------------------------------------------------------------
Add a DOM element to all paragraphs
HTML code:

I wowould like to say:


I wowould like to say:


Hello
Good Bye
JQuery code:
$ ("P"). prepend ($ (". foo") [0]);
Result:

HelloI wowould like to say:


HelloI wowould like to say:


Hello
Good Bye
--------------------------------------------------------------------------------
Add a jQuery object (similar to a DOM element array) to all paragraphs ).
HTML code:

I wowould like to say:

Hello
JQuery code:
$ ("P"). prepend ($ ("B "));
Result:

HelloI wowould like to say:


Certificate --------------------------------------------------------------------------------------------------------------------------------------------------
PrependTo (content)
All matched elements are prefixed to another set of specified Element elements.
In fact, this method is used to reverse the conventional $ (A). prepend (B) operation, that is, not to prefix B to A, but to Prefix A to B.
--------------------------------------------------------------------------------
Prepend all of the matched elements to another, specified, set of elements.
This operation is, essential, the reverse of doing a regular $ (A). prepend (B), in that instead of prepending B to A, you're prepending A to B.
Return Value
JQuery
Parameters
Content (String): jQuery expression used to match Elements
Example
Append all paragraphs to the element with the ID value foo.
HTML code:

I wowould like to say:


JQuery code:
$ ("P"). prependTo ("# foo ");
Result:

I wowould like to say:


Certificate --------------------------------------------------------------------------------------------------------------------------------------------------
After (content)
Insert content after each matching element.
--------------------------------------------------------------------------------
Insert content after each of the matched elements.
Return Value
JQuery
Parameters
Content (String, Element, jQuery): content inserted to each target
Example
Insert HTML code after all paragraphs.
HTML code:

I wowould like to say:


JQuery code:
$ ("P"). after (" Hello");
Result:

I wowould like to say:

Hello
--------------------------------------------------------------------------------
Insert a DOM element after all paragraphs.
HTML code:
Hello

I wowould like to say:


JQuery code:
$ ("P"). after ($ ("# foo") [0]);
Result:

I wowould like to say:

Hello
--------------------------------------------------------------------------------
Insert a jQuery object (similar to a DOM element array) After all paragraphs ).
HTML code:
Hello

I wowould like to say:


JQuery code:
$ ("P"). after ($ ("B "));
Result:

I wowould like to say:

Hello
Certificate --------------------------------------------------------------------------------------------------------------------------------------------------
Before (content)
Insert content before each matching element.
--------------------------------------------------------------------------------
Insert content before each of the matched elements.
Return Value
JQuery
Parameters
Content (String, Element, jQuery): content inserted before each target
Example
Insert HTML code before all paragraphs.
HTML code:

I wowould like to say:


JQuery code:
$ ("P"). before (" Hello");
Result:
[ Hello

I wowould like to say:

]
--------------------------------------------------------------------------------
Insert an element before all paragraphs.
HTML code:

I wowould like to say:

Hello
JQuery code:
$ ("P"). before ($ ("# foo") [0]);
Result:
Hello

I wowould like to say:


--------------------------------------------------------------------------------
Insert a jQuery object (similar to a DOM element array) before all paragraphs ).
HTML code:

I wowould like to say:

Hello
JQuery code:
$ ("P"). before ($ ("B "));
Result:
Hello

I wowould like to say:


Certificate --------------------------------------------------------------------------------------------------------------------------------------------------
InsertAfter (content)
Insert all matching elements to the end of another specified element set.
In fact, this method is used to reverse the conventional $ (A). after (B) operation, that is, not to insert B to A, but to insert A to B.
--------------------------------------------------------------------------------
Insert all of the matched elements after another, specified, set of elements.
This operation is, essential, the reverse of doing a regular $ (A). after (B), in that instead of inserting B after A, you're inserting A after B.
Return Value
JQuery
Parameters
Content (String): jQuery expression used to match Elements
Example
Insert an element after all paragraphs. Same as $ ("# foo"). after ("p ")
HTML code:

I wowould like to say:

Hello


JQuery code:
$ ("P"). insertAfter ("# foo ");
Result:

Hello

I wowould like to say:


Certificate -------------------------------------------------------------------------------------------------------------------------------------------------
InsertBefore (content)
Insert all matching elements to the front of another specified element set.
In fact, this method is used to reverse the conventional $ (A). before (B) operation, that is, not to insert B to A, but to insert A to B.
--------------------------------------------------------------------------------
Insert all of the matched elements before another, specified, set of elements.
This operation is, essential, the reverse of doing a regular $ (A). before (B), in that instead of inserting B before A, you're inserting A before B.
Return Value
JQuery
Parameters
Content (String): jQuery expression used to match Elements
Example
Insert an element before all paragraphs. Same as $ ("# foo"). before ("p.
HTML code:

Hello

I wowould like to say:


JQuery code:
$ ("P"). insertBefore ("# foo ");
Result:

I wowould like to say:

Hello

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.