jquery Basic Learning 1

Source: Internet
Author: User

The standard HTML file introduces the jquery library approach:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "><!--introduced jQuery--><script src=". /scripts/jquery.js "type=" Text/javascript "></script><script type=" Text/javascript ">// Wait for the DOM element to load. $ (document). Ready (function () {alert ("Hello world!");}); </script>

1. In the jquery library, $ is a shorthand for jquery, $ ("#foo") and jquery ("#foo") are equivalent, and $.ajax and Jquery.ajax are equivalent.

2.$ (document). Ready (function () {...}); This method is similar to the Window.onload method in traditional JavaScript; All code in the Ready () function will be executed in advance (as long as the DOM is registered in the browser) and not on the page ( The contents of the bandwidth occupied by the sample are fully loaded before the event is executed; it allows the user to immediately see the shadow effect, display effect, and other effects of the element when they first see the element.

The 3.$ (document). Ready () function can be called repeatedly in code.

4.$ (function () {...}); is $ (document). Ready (function () {...}); Short form, the two functions are exactly the same.

5. How to introduce an external CSS file

<link rel= "stylesheet" href= "Css/default.css" type= "Text/css"/>

Comments for 6.jQuery Code

Single-line comment using//method

Multi-line annotations in/*......*/way

jquery Basic Learning 1

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.