Basic jQuery knowledge, jquery
The upgraded version of JS framework encapsulates JS.
File Suffix:. min. js min compressed version
Method: The script label src = "jquery" must be loaded at the top.
Element searching
Var a = document. getElementById ("aa ");
Alert ();
Var a = document. getElementsByClassName ("a1 ");
Alert (a [2]);
Document. getElementsByTagName ("div ");
Var a = document. getElementsByName ("uid ");
Alert (a [0]);
Operation content
Non-standard single element
Alert (a. innerText); text
Alert (a. innerHTML); HTML code
Form Element
Alert (a. value );
A. value = "hello ";
Operation attribute
A. setAttribute ("test", "test ");
A. removeAttribute ("test ");
Alert (a. getAttribute ("value "));
Operation Style
A. style. fontSize = "30px ";
Alert (a. style. color );
Unified operation Element
Var d = document. getElementsByClassName ("a1 ");
For (var I = 0; I <d. length; I ++)
{
D [I]. style. fontSize = "30px ";
}
Element searching
Var a = $ ("# aa ");
Alert ();
Var a = $ (". a1 ");
Alert (a. eq (2 ));
Var a = $ ("div ");
Var a = $ ("[bs = 1]");
Alert ();
Operation content
Non-form Element
Alert (a. text ());
A. text ("bbbbb ");
Alert(a.html ());
Form Element
A. val ("hello ");
Operation attribute
A. attr ("test", "test ");
A. removeAttr ("test ");
Alert (a. attr ("value "));
A. prop ("test", "test ");
A. removeProp ("test ");
Alert (a. prop ("test "));
A. prop ("checked", true );
Alert (a. prop ("checked "));
Operation Style
A.css ("background-color", "green ");
Alert(a.css ("width "));
Unified operation Element
$ (". A1" ).css ("font-size", "30px ");
$ (". Ck"). prop ("checked", true );
Event
$ ("# Ck"). click (function (){
Alert ($ (this ));
$ (This) select its own element
$ (". Ck"). prop ("checked", $ (this). prop ("checked "));
}) Anonymous Functions
$ (". Ck"). click (function (){
Alert ("bb ");
})
In the event method, $ (this) selects its own element.