1. Precise and simple Selection object (DOM):
$ (' #element ');//equivalent to document.getElementById ("element") $ ('. element ');//class $ (' P ');//html label
$ ("form > Input");//Sub-object
$ ("Div,span,p.myclass");//Select multiple objects at the same time
$ ("tr:odd"). CSS ("Background-color", "#bbbbff");///Table interlaced background $ (": input");//Form Object
$ ("input[name= ' newsletter ')");//Specific Form Object
2. The application of object functions is simple and unlimited:
Element.function (PAR);
$ ("P.surprise"). AddClass ("Ohmy"). Show ("Slow") ...
3. Actions on selected objects (including styles):
$ ("#element"). AddClass ("selected");//Add a style to an object
$ (' #element '). CSS ({"Background-color": "Yellow", font-weight ":" Bolder "});//Change Object style
$ ("P"). Text ("Some new text."); /Change Object text
$ ("img"). attr ({src: "test.jpg", alt: "Test Image"});//Change object Text $ ("P"). Add ("span");//Add label to Object
$ ("P"). FIND ("span");//finds the corresponding element within the object $ ("P"). parent ();//The parents element of the object
$ ("P"). Append ("<b>Hello</b>");//Add content to an object
4. Support AJAX, support file format: XML/HTML/SCRIPT/JSON/JSONP
$ ("#feeds"). Load ("feeds.html");//import static page contents into corresponding area
$ ("#feeds"). Load ("feeds.php", {limit:25}, function () {alert ("The last entries in the feed has been loaded"); /Import Dynamic Content
4. Support for events:
$ ("P"). Hover (function () {$ (this). addclass ("Hilite");//When the mouse is put on,
Function () {$ (this). Removeclass ("Hilite");//Remove mouse
});//different effects of mouse on and off (auto loop all P objects)
5. Animations:
$ ("P"). Show ("slow");//hidden Object (slow gradient)
$ ("#go"). Click (function () {
$ ("#block"). Animate ({
Width: "90%",
Height: "100%",
FontSize: "10em"
}, 1000);
});//mouse click on the width, height, font dynamic changes
6. Extensions:
$.fn.background = function (BG) {
return this.css (' background ', BG);
};
$ (#element). Background ("Red");
If you want to add a function for each JQuery object, you must assign the function to $.fn, and the function must return a This (jquery object)
Some features and usage of jquery