Knowledge Point Grooming
1, Common JavaScript libraries
Prototype Old JS Library. Yui Yahoo pushed the JS library. ExtJS,,,,. The open source project, created by jquery in January 2006. The jquery team includes core libraries, UIs, plugins, jquery mobile, and more
Advantages of 2,jquery
(1) Lightweight
(2) Powerful selector
(3) Excellent DOM operation encapsulation
(4) A reliable event handling mechanism
(5) Perfect Ajax
(6) Non-polluting top-level variables
(7) Excellent browser compatibility
(8) Chain-operated mode
(9) Implicit iteration
(10) Separation of behavioral and structural layers
(11) Rich plug-in support
(12) Complete documentation
(13) Open source
3, how to start writing JS code using the jquery library
jquery Library on a file, the distribution version is about 30KB, the development version is around 2,300KB. We recommend using a CDN from Baidu to refer to the jquery library. Baidu's speed in our country is still good. As for what the CDN is, check it out for yourself.
<type= "Text/javascript" src= "http://apps.bdimg.com/libs/jquery/ 2.1.1/jquery.min.js "></script>
4, everything starts with a function
jquery provides a function to make. These two functions are different ways of writing the same function. All of the DOM structures in the Web page are drawn to execute the method. Unlike traditional window.onload, the former does not need to wait for a picture to be downloaded and then execute the function, and it can be registered multiple times and executed sequentially.
<Scripttype= "Text/javascript"CharSet= "Utf-8">$ (document). Ready (function() {alert ('Hello World'); }); $(function() {alert ('Again Hello world'); });</Script>
5,jquery Objects and Dom objects
Objects obtained using native JavaScript methods are both DOM objects. Use $ () to get an array-like jquery object. The $ () function will return a jquery object anyway. It is possible to determine if the corresponding element is found by length before use.
<DivID= "Content"> <DivID= "Head">This is the head .</Div> <DivID= "Main">This is the content area</Div> <DivID= "Bottom">This is the bottom</Div> </Div> <Scripttype= "Text/javascript"> $(function () { //This is the DOM object varDomobj=document.getElementById ("Head"); //This is the jquery object var$OBJ= $('#head'); //Len has a value of 1 varLen=$Obj. Length; //DOM object converted to jquery object varresult=$ (domobj); //jquery objects converted to DOM objects varDomresult=$OBJ [0]; Domresult=$Obj. Get (0); }) </Script>
6. Resolve conflict issues with other libraries. Using custom aliases
The jquery library uses only one top-level variable object, jquery, whose alias is $.
jquery was introduced before other libraries, using the following method
Sharp jquery The first chapter