jquery is packaged on the basis of JS
-1. Compatibility
-2. Simplicity
-3. Compact
-4. Widely used
jquery to JS $ ();
JS to jquery get ();
* * Selector: * *
-$ ("P") select all P elements.
-$ ("P.intro") selects all P elements that contain the class "Intro".
-$ ("#demo") Select the element with the ID "demo".
-$ ("[href]") selects all elements with an href attribute.
-$ ("[href= ' # ']") selects all elements with an HREF value equal to "#".
-$ ("[href!= ' # ']") selects all elements with an HREF value that is not equal to "#".
-$ ("[href$=. jpg]") selects all elements with an href value ending with ". jpg".
-$ ("[href^= '/imgaes/']") selects all elements that begin with an HREF value of/imgaes/.
* * Common method of function * *
Bind (TYPE,[DATA],FN) binds an event to a matching element
Code:
$ ("P"). Bind ("click", Function () {
Alert ($ ("P"). html ());
});
css (Name,value) Set style for element
Code:
$ ("P"). CSS ("Color", "red");
if multiple styles,
$ ("P"). css ({
" Color ":" Red ",
" Border ":" 1px Solid blue ",
" width ": 100px",
"height": "100px",
});
< Span style= "color: #008000;" >
addclass (Class) and Removeclass (class) Add styles and remove styles to achieve a dynamic style effect. &NBSP;&NBSP;
Code:
$ (". Stripe tr"). Bind ("MouseOver", function () {
$ (This). AddClass (Class);
or
$ (This). Removeclass (Class);
&NBSP;&NBSP;&NBSP;&NBSP;});
< Span style= "color: #008000;" >
attr (key,value) Add property to Element
Code:
$ ("img"). attr ("src", "test.jpg");
appendto (content) adds the matched element to another specified element.
code
$ (a). AppendTo (b) adds a to the B element, where it is added and so on moves A to the B element.
JQuery (i)