Introduction to JQuery Tutorial (ii): basic syntax

Source: Internet
Author: User

Before learning jquery you need to have some basic knowledge of the following

    • Html
    • Css
    • Javascript
The basic syntax of jQuery

$ (selector). Action ()

    • $ compliant Definition This is a jquery statement
    • (selector) is used to select an HTML element whose syntax is the same as the selector syntax of a CSS.
    • Action () defines the method that operates the HTML element.

Like what:

$ (this). Hide () – hides the current element.

$ ("P"). Hide () – hides so <p> elements.

$ (". Test"). Hide ()-hides the element that is the class name test.

$ ("#test"). Hide ()-hides the element with ID test.

Document Ready Events

Almost all jquery has the following code:

$ (document). Ready (function () {   

This is the document ready event handler to prevent jquery from executing before the page is loaded. This avoids the following similar situations:
Trying to hide an element that has not yet been created
Trying to get the size of a picture that has not been loaded

This method can also be used in the following simplified way:

$ (function () {   

You can choose the way you like, but you usually use $ (document). Ready (function () {To facilitate the reading of the code.

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.