Interpretation JQuery source (Miao taste auditorium - Video Notes - a first part)

 
 
 1.1 define some variables and functions jQuery = fuction () {}
 
 
 
1.2 Adding methods and properties to the object JQ
 
 
1.3 extend: the inherited method jQ
 
 
 
1.4 jQuery.extend () extension method some tools
 
 
1.5 Sizzle: implement complex selector
 
1.6 Callback: swap the unified management of objects, functions
 
function fun1(){
   console.log(1)
}
function fun2(){
  console.log(2)
}
 
 var cb = $.Callback();
cb.add(fun1);
cb.add(fun2) ;
cb.fire(); // 1,2
 
cb.remove(fun1)
 
 
cb.fire (); // 2 fun1 removed
 
 
 
1.7 Deferred: lingering objects, asynchronous unified management
 
 
setTimeout(function(){
       console.log(1);
})
console.log(2)
 
 
// first output 2, output 1 setTimeout asynchronous function
 
var dfd = $ .Deferred (); // Create a lingering objects
 
setTimeout(function(){
    console.log(1)
  dfd.resolve(); 
})
 
dfd.done(function(){
   console.log(2)
})
 
// first output 1, output 2
// first with deferred save function, and then use a callback function to call back the way
 
 
 
 
1.8 support: function test
 
// function tests: browser version changes fast, the browser function will not change, detect the browser version in the form of features, more stable
 
 
1.9 data (): data storage 
 
$ ( "# Div") data (name: "Hello"). // add a name to the id value of the property to Hello nodes of div
 
$("div").data("name");// Hello
 
 
 
1.10 queue (): Queue Management
 
$("#div1").animate({left:100});
 
$("#div1").animate({top:100});
 
$("#div1").animate({width:300});
 
// queue management movement, order management functions like
 
 
1.11 attr () prop () val () addClass () and the like, the operation of the element attribute
 
 
 
1.12 on () trigger (): Event actions related methods
 
 
 
1.13 DOM: Add append delete empty () remove () Gets innerHTML packaging wrap
 
 
 
1.14 css (): Style style operations compatible processing operation boxSize
 
 
1.15 submitted data and Ajax () ajax script tag package load ()
 
 Method of packaging animation 1.16
     animate();
 
 
1.17 offset () scrollTop () method of packaging position and screen size
 
 
1.18 JQuery support modular model
         AMD modular front-end support
         Common back-end modular support
         
 
 
 
1.19 window.jQuery = window.$ = jquery

Guess you like

Origin www.cnblogs.com/SunlikeLWL/p/11355666.html