Tutorials | sample |jquery DOM Operations
Property
We take As an example, in the original JavaScript can use Var O=document.getelementbyid (' a ') to take the ID of a node object, When you use O.SRC to get or modify the SCR properties of the node, in jquery $ ("#a") will get the jquery object [], which can then be manipulated in many ways that jquery provides, such as $ ("# A "). SCR () will get 5.jpg,$ (" #a "). SCR (" 1.jpg ") changes the object Src property to 1,jpg. Here's a list of the many jquery methods that jquery offers to make it easy to manipulate DOM objects quickly
Herf () Herf (Val)
Description: Herf the jquery object properties.
Example:
No jQuery before jQueryjquery Code and functionality:
function JQ () {
Alert ($ ("#test"). href ());
$ ("#test"). href ("2.html");
}Run: First pop-up dialog box to display the connection URL with ID test, change its URL to 2.html, when the pop-up dialog will see the switch to 2.html
In the same way, jquery offers a similar alternative, and you can experiment with each:
Herf () Herf (val) HTML () HTML (val) ID () ID (val) name () name (val) rel () rel (val)
SRC () src (val) title () title (Val) Val () Val (Val)
Operation
After (HTML) inserts a section of HTML jquery code and functionality after the matching element:
Append (HTML) inserts the specified HTML jquery code and functionality at the end of the matching element:
jQuery function JQ () {
$ ("#test"). After ("Hello");
}After execution is equivalent to:
jQueryHelloAfter (Elem) after (elems) inserts the specified object Elem or object group elems into the matching element
after
jQueryjquery Code and functionality
function JQ () {
$ ("a"). After ($ ("#test"));
}Executed after the equivalent
jqueryafter
jQuery function JQ () {
$ ("#test"). Append ("Hello");
}Executed after the equivalent
jQueryHelloSimilarly there are append (elem) append (Elems) before (HTML) before (Elem) before (Elems) please perform the Append test and understand the callers and after.
appendto (expr) is the opposite of append (Elem) Clone () copy a jquery object empty () Delete all child nodes of the matching object
after
jQueryjquery Code and functionality
function JQ () {
$ ("a"). Appendto ($ ("#test"));
}Executed after the equivalent
afterjQuery
after
jQueryjquery Code and functionality:
function JQ () {
$ ("#test"). Clone (). Appendto ($ ("a"));
}Copy $ ("#test") and insert into after execution equivalent to
after
jqueryafter
jQueryjquery Code and functionality:
function JQ () {
$ ("#test"). empty ();
}Executed after the equivalent
jQuery
InsertAfter (expr) insertbefore (expr)
According to the official explanations and my few simple tests InsertAfter (expr) are equivalent to before (Elem), insertbefore (expr) equals after (Elem)
Prepend (HTML) prepend (elem) prepend (Elems) is inside of the matching element and begins to insert
Differentiate append (elem) appendto (expr) prepend (Elem) by the following example
p
div
Execute $("#a"). Append ($ ("div")) after the equivalent
P
div
Execute $ ("#a"). Appendto ($ ("div")) after the equivalent
Execute $ ("#a"). Prepend ($ ("div")) after the equivalent
div
P