jquery basic Syntax

Source: Internet
Author: User


$ (this). Hide ()
Demonstrates the Hide () function of JQuery, hiding the current HTML element.
$ ("P"). Hide ()
Demonstrates the Hide () function of jQuery, hiding all <p> elements.
$ (". Test"). Hide ()
Demonstrates the Hide () function of jQuery, hiding all elements of the class= "test".
$ ("#test"). Hide ()
Demonstrates JQuery's hide () function, which hides elements of the id= "test".

$ ("[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".

JQuery CSS Selector

The JQuery CSS selector can be used to change the CSS properties of HTML elements.

The following example changes the background color of all p elements to red:
Instance

$ ("P"). CSS ("Background-color", "Red");


$ (this) current HTML element
$ ("P") all <p> elements
$ ("P.intro") <p> elements for all class= "Intro"
$ (". Intro") All Elements of class= "Intro"
$ ("#intro") id= Elements of "Intro"
$ ("ul Li:first") the first <li> element of each <ul>
$ ("[href$= '. jpg ']") all href attributes with attribute values ending with ". jpg"
$ ("Div#intro. Head") id= all class= "head" elements in the <div> element of "Intro"

jquery Events


Here are some examples of the event methods in JQuery:
The Event function binds the function to the
$ (document). Ready (function) binds functions to a document's readiness event (when the document finishes loading)
$ (selector). Click to trigger or bind a function to a clicked event of the selected element
$ (selector). DblClick (function) triggers or binds a function to a double-click event of the selected element
$ (selector). focus (function) triggers or binds a function to the Focusable event of the selected element
$ (selector). mouseover (function) triggers or binds a function to a mouse hover event of the selected element




JQuery Fading Method

FadeIn ()//for fading in hidden elements
FadeOut ()//for fading out visible elements
Fadetoggle ()//fadein () and fadeout (), the parentheses can add time to show and hide the speed;
The FadeTo ()//method allows the gradient to be given opacity (values between 0 and 1).

jquery Swipe


The Slidedown () method is used to slide the element down. $ (selector). Slidedown (Speed,callback);
The Slideup () method is used to slide the element up. Syntax: $ (selector). Slideup (Speed,callback);
Slidetoggle () Toggles between the Slidedown () and the Slideup () method. $ (selector). Slidetoggle (Speed,callback);


Animate custom Animations


Get Property-attr ()

jquery basic Syntax

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.