operation of the DOM node--jqueryInternal Insert 1, (end) Append method, Appendto method (to facilitate chained operation) (beginning) Prepend method
$ (' #div1 '). Append ($ (' #div2 ')); //Insert the DIV2 into the end of the Div1
?
$ (' #div1 '). appendto ($ (//) Insert Div1 at the end of the Div2
?
$ (' #div1 '). prepend ($ (' #div2 ')); //Insert the DIV2 into the beginning of the Div1
?
$ (' #div1 '). prependto ($ (//) insert Div1 into the beginning of div2
External operation () after method, before method
() InsertAfter method, InsertBefore method
$ (' #h2 '). After ($ (//Insert Div2 to the end of H2
?
$ (' #h2 '). before ($ (//Insert Div2 in front of H2
Wrapping method Wrap Method Replace Method ReplaceWith () method can be filled in the label
$ (' #div1 '). replacewith ($ (
$ (' #div2 '). ReplaceAll ($ (' #div1 '));
Delete
$ (' #div1 '). empty (); //Delete the contents of Div1
?
Copy Clone filter
Filter
EQ () //Select one, result for jquery object note with get () distinguished, get (), result as native object
First () //Get the number one
Get the last one
Hasclass (' class name ') //Yes, return, true No, return false
?
Event handling (bubbling phase)
Binding events
function fn () {
Console. log (
}
?
$ (' P '). On (' click ',fn);
?
Unbind Event
$ (' P '). Off (' click ',fn);
?
?
Page Load Completion events
$ (document). Ready (function () {
})
Event delegate
Ul. onclick=function (event) {
if (event. Taget. nodeName= = =LI) {
Console. log (event. Taget.
}
}
?
?
$ (' #ul '). On (' click ',' li ',function () {
Console. log ($ (this). HTML ());
})
Operation of the DOM node