Juqery five-document processing and insertion

Source: Internet
Author: User

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:
<P> I wowould like to say: </p>
JQuery code:
$ ("P"). append ("<B> Hello </B> ");
Result:
[<P> I wowould like to say: <B> Hello </B> </p>]
-
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:
<P> I wocould like to say: </p> <div id = "foo"> </div>
JQuery code:
$ ("P"). appendTo ("# foo ");
Result:
<Div id = "foo"> <p> I wocould like to say: </p> </div>
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:
<P> I wowould like to say: </p>
JQuery code:
$ ("P"). prepend ("<B> Hello </B> ");
Result:
[<B> Hello </B> <p> I wowould like to say: </p>]
--------------------------------------------------------------------------------
Add a DOM element to all paragraphs
HTML code:
<P> I wowould like to say: </p>
<P> I wowould like to say: </p>
<B class = "foo"> Hello </B>
<B class = "foo"> Good Bye </B>
JQuery code:
$ ("P"). prepend ($ (". foo") [0]);
Result:
<P> <B class = "foo"> Hello </B> I wowould like to say: </p>
<P> <B class = "foo"> Hello </B> I wowould like to say: </p>
<B class = "foo"> Hello </B>
<B class = "foo"> Good Bye </B>
--------------------------------------------------------------------------------
Add a jQuery object (similar to a DOM element array) to all paragraphs ).
HTML code:
<P> I wowould like to say: </p> <B> Hello </B>
JQuery code:
$ ("P"). prepend ($ ("B "));
Result:
<P> <B> Hello </B> I wocould like to say: </p>
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:
<P> I wocould like to say: </p> <div id = "foo"> </div>
JQuery code:
$ ("P"). prependTo ("# foo ");
Result:
<Div id = "foo"> <p> I wocould like to say: </p> </div>
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:
<P> I wowould like to say: </p>
JQuery code:
$ ("P"). after ("<B> Hello </B> ");
Result:
<P> I wowould like to say: </p> <B> Hello </B>
--------------------------------------------------------------------------------
Insert a DOM element after all paragraphs.
HTML code:
<B id = "foo"> Hello </B> <p> I wowould like to say: </p>
JQuery code:
$ ("P"). after ($ ("# foo") [0]);
Result:
<P> I wowould like to say: </p> <B id = "foo"> Hello </B>
--------------------------------------------------------------------------------
Insert a jQuery object (similar to a DOM element array) After all paragraphs ).
HTML code:
<B> Hello </B> <p> I wocould like to say: </p>
JQuery code:
$ ("P"). after ($ ("B "));
Result:
<P> I wowould like to say: </p> <B> Hello </B>
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:
<P> I wowould like to say: </p>
JQuery code:
$ ("P"). before ("<B> Hello </B> ");
Result:
[<B> Hello </B> <p> I wowould like to say: </p>]
--------------------------------------------------------------------------------
Insert an element before all paragraphs.
HTML code:
<P> I wowould like to say: </p> <B id = "foo"> Hello </B>
JQuery code:
$ ("P"). before ($ ("# foo") [0]);
Result:
<B id = "foo"> Hello </B> <p> I wowould like to say: </p>
--------------------------------------------------------------------------------
Insert a jQuery object (similar to a DOM element array) before all paragraphs ).
HTML code:
<P> I wowould like to say: </p> <B> Hello </B>
JQuery code:
$ ("P"). before ($ ("B "));
Result:
<B> Hello </B> <p> I wocould like to say: </p>
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:
<P> I wocould like to say: </p> <div id = "foo"> Hello </div>
JQuery code:
$ ("P"). insertAfter ("# foo ");
Result:
<Div id = "foo"> Hello </div> <p> I wowould like to say: </p>
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:
<Div id = "foo"> Hello </div> <p> I wowould like to say: </p>
JQuery code:
$ ("P"). insertBefore ("# foo ");
Result:
<P> I wocould like to say: </p> <div id = "foo"> Hello </div>

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.