Some features and usage of jquery

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.