JQuery (i)

Source: Internet
Author: User

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)

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.