Juqery Learning five document processing insert _jquery

Source: Internet
Author: User
Tags html tags
Append (content)
Appends content to each matching element.
This action is similar to the way that the AppendChild method is executed on the specified elements and added to the document.
--------------------------------------------------------------------------------
Append content to the inside of every matched element.
This operation was similar to doing a appendchild to the specified elements and adding into the document.
return value
Jquery
Parameters
Content (String, Element, jQuery): C to append to the target
Example
Append some HTML tags to all paragraphs.
HTML Code:
<p>i would like to say: </p>
JQuery Code:
$ ("P"). Append ("<b>Hello</b>");
Results:
[<p>i would like to say: <b>Hello</b></p>]
-
--------------------------------------------------------------------------------------------------------------- -----------------------------------
appendto (content)
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.
--------------------------------------------------------------------------------
Append all of the matched elements to another, specified, set of elements.
This operation are, essentially, the reverse of doing a regular $ (a). Append (b), in which instead of appending B to a, you ' re Appending A to B.
return value
Jquery
Parameters
Content (String): Used for additions
Example
Append all paragraphs to an element with an ID value of foo.
HTML Code:
<p>i would like to say: </p><div id= "foo" ></div>
JQuery Code:
$ ("P"). Appendto ("#foo");
Results:
<div id= "foo" ><p>i would like to say: </p></div>
--------------------------------------------------------------------------------------------------------------- -----------------------------------
Prepend (content)
The content is placed in front of each matching element.
This is the best way to insert content at the beginning of all matching elements.
--------------------------------------------------------------------------------
Prepend content to the inside of every matched element.
This operation was the best way to insert elements inside in the beginning, of all matched.
return value
Jquery
Parameters
Content (String, Element, jQuery): What to insert into the front of the target element
Example
Forward some HTML markup code to all paragraphs.
HTML Code:
<p>i would like to say: </p>
JQuery Code:
$ ("P"). Prepend ("<b>Hello</b>");
Results:
[<b>hello</b><p>i would like to say: </p>]
--------------------------------------------------------------------------------
Place a DOM element before all paragraphs
HTML Code:
<p>i would like to say: </p>
<p>i would like to say: </p>
<b class= "foo" >Hello</b>
<b class= "foo" >good bye</b>
JQuery Code:
$ ("P"). Prepend ($ (". Foo") [0]);
Results:
<p><b class= "foo" >hello</b>i would like to say: </p>
<p><b class= "foo" >hello</b>i would like to say: </p>
<b class= "foo" >Hello</b>
<b class= "foo" >good bye</b>
--------------------------------------------------------------------------------
A jquery object (similar to an array of DOM elements) is placed before all paragraphs.
HTML Code:
<p>i would like to say: </p><b>Hello</b>
JQuery Code:
$ ("P"). Prepend ($ ("B"));
Results:
<p><b>hello</b>i would like to say: </p>
--------------------------------------------------------------------------------------------------------------- -----------------------------------
Prependto (content)
Sets all matching elements forward to another, specified set of element elements.
In fact, using this method reverses the operation of the conventional $ (A). Prepend (b), that is, instead of putting B in front of a, you are placing A in front of B.
--------------------------------------------------------------------------------
Prepend all of the matched elements to another, specified, set of elements.
This operation are, essentially, the reverse of doing a regular $ (a). Prepend (b), in which instead of prepending B to A, you ' Re prepending A to B.
return value
Jquery
Parameters
Content (String): A jquery expression used to match elements
Example
Append all paragraphs to an element with an ID value of foo.
HTML Code:
<p>i would like to say: </p><div id= "foo" ></div>
JQuery Code:
$ ("P"). Prependto ("#foo");
Results:
<div id= "foo" ><p>i would like to say: </p></div>
--------------------------------------------------------------------------------------------------------------- -----------------------------------
After (content)
Inserts the content after each matching element.
--------------------------------------------------------------------------------
Insert content after each of the matched elements.
return value
Jquery
Parameters
Content (String, Element, jQuery): What is inserted after each target
Example
Insert some HTML tag code after all the paragraphs.
HTML Code:
<p>i would like to say: </p>
JQuery Code:
$ ("P"). After ("<b>Hello</b>");
Results:
<p>i would like to say: </p><b>Hello</b>
--------------------------------------------------------------------------------
Inserts a DOM element after all the paragraphs.
HTML Code:
<b id= "foo" >hello</b><p>i would like to say: </p>
JQuery Code:
$ ("P"). After ($ ("#foo") [0]);
Results:
<p>i would like to say: </p><b id= "foo" >Hello</b>
--------------------------------------------------------------------------------
Inserts a jquery object (similar to an array of DOM elements) after all the paragraphs.
HTML Code:
<b>hello</b><p>i would like to say: </p>
JQuery Code:
$ ("P"). After ($ ("B"));
Results:
<p>i would like to say: </p><b>Hello</b>
--------------------------------------------------------------------------------------------------------------- -----------------------------------
Before (content)
Inserts the content before each matching element.
--------------------------------------------------------------------------------
Insert content before each of the matched elements.
return value
Jquery
Parameters
Content (String, Element, jQuery): What is inserted before each target
Example
Inserts some HTML markup code before all the paragraphs.
HTML Code:
<p>i would like to say: </p>
JQuery Code:
$ ("P"). Before ("<b>Hello</b>");
Results:
[<b>hello</b><p>i would like to say: </p>]
--------------------------------------------------------------------------------
Inserts an element before all the paragraphs.
HTML Code:
<p>i would like to say: </p><b id= "foo" >Hello</b>
JQuery Code:
$ ("P"). Before ($ ("#foo") [0]);
Results:
<b id= "foo" >hello</b><p>i would like to say: </p>
--------------------------------------------------------------------------------
Inserts a jquery object (similar to an array of DOM elements) before all paragraphs.
HTML Code:
<p>i would like to say: </p><b>Hello</b>
JQuery Code:
$ ("P"). Before ($ ("B"));
Results:
<b>hello</b><p>i would like to say: </p>
--------------------------------------------------------------------------------------------------------------- -----------------------------------
InsertAfter (content)
Inserts all matching elements behind another, specified set of element elements.
In fact, using this method reverses the normal $ (A). After (b) operation, that is, instead of inserting b behind a, insert a into the B.
--------------------------------------------------------------------------------
Insert all of the matched elements after another, specified, set of elements.
This operation are, essentially, the reverse of doing a regular $ (a). After (b), in which instead of inserting B after a, you ' Re inserting A after B.
return value
Jquery
Parameters
Content (String): A jquery expression used to match elements
Example
Inserts an element after all the paragraphs. and $ ("#foo"). After ("P") the same
HTML Code:
<p>i would like to say: </p><div id= "foo" >Hello</div>
JQuery Code:
$ ("P"). InsertAfter ("#foo");
Results:
<div id= "foo" >hello</div><p>i would like to say: </p>
--------------------------------------------------------------------------------------------------------------- ----------------------------------
InsertBefore (content)
Inserts all matching elements in front of another, specified set of element elements.
In fact, using this method reverses the normal $ (A). Before (b) operation, that is, not inserting B into front of a, but inserting A in front of B.
--------------------------------------------------------------------------------
Insert all of the matched elements before another, specified, set of elements.
This operation are, essentially, the reverse of doing a regular $ (a). Before (b), in that instead of inserting B before a, yo U ' re inserting A before B.
return value
Jquery
Parameters
Content (String): A jquery expression used to match elements
Example
Inserts an element before all the paragraphs. Same as $ ("#foo"). Before ("P").
HTML Code:
<div id= "foo" >hello</div><p>i would like to say: </p>
JQuery Code:
$ ("P"). InsertBefore ("#foo");
Results:
<p>i would 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.