1.addBack ()
A. Third-item's Li next several neighboring nodes (including Third-item)
$ ("Li.third-item"). Nextall (). Addback ().
CSS ("Background-color", "Red");
B. Similar to the end () method, the Div.after-addback and P elements are selected, and end is selected with the Div.after-addback element
$ ("Div.after-addback"). Find ("P"). Addback (). addclass ("background");
2.callback.fire ()
Call foo function via argument
var foo = function (value) {
console.log ("foo:" + value);
}
var callbacks = $. Callbacks ();
Callbacks.add (foo);
Callbacks.fire ("Hello");
Callbacks.fire ("World");
3.callback.lock ()
Lock the callback function list, this method cannot accept any arguments.
var foo = function (value) {
console.log ("foo:" + value);
var bar = function (value) {
console.log ("bar:" + value);
}
var callbacks = $. Callbacks ();
Callbacks.add (foo);
Callbacks.fire ("Hello"); The output "Foo:hello"
callbacks.lock ();///The Foo method cannot be invoked thereafter unless $. Callbacks ("Memory"), you can add a function
Callbacks.fire ("World");//No Call to Foo method
Callbacks.add (bar);////When callbacks assignment is $. Callbacks ("Memory"), creates a callback object, uses the memory identifier, can add a function
Callbacks.fire ("World");/output "Bar:hello"
4.defered.promise ()
Returns another deferred object on the original deferred object
$ (function () {
$ ("Input[type=button]"). Click (function () {
$.ajax ({
URL: "validate.html",
type: " POST ",
dataType:" JSON "
}). Done (function (data) {
alert (DATA.A);
}). Fail (function () {
alert ("error");
})
;
var DTD = $. Deferred ();
var wait = function (DTD) {
var tasks = function () {
alert (completed!) ");
Dtd.resolve (); Change the execution state of the deferred object
}; SetTimeout (tasks,5000);
};
Dtd.promise (wait);
Wait.done (function () {alert ("Haha, success!") "); }). Fail (function () {alert ("Error!) ");
});
5.animate ({step:function () {}})
Animation of one element while another element is animated
$ ("#go"). Click (function () {
$ (". Block:first"). Animate ({
left:100
}, {
duration:1000, step
: function (now, FX) {
$ (". BLOCK:GT (0)"). CSS (' left ', Now ';}}});
6.clone ()
Use with the Appendto method to create a cloned element
<div class= "Container" >
<div class= "Hello" >Hello</div>
<div class= "Goodbye" > Goodbye</div>
The result:
<div class= "Container" >
<div class= "Goodbye" >
goodbye <div class=
"Hello" >hello </div>
</div>
</div>
The result:
<div class= "Container" >
<div class= "Hello" >Hello</div>
<div class= "Goodbye" >
Goodbye
<div class= "Hello" >Hello</div>
</div>
</div>
The above is a small series for everyone to talk about jquery Advanced method description and application of all content, I hope that we support cloud-Habitat Community ~