JQuery no-nonsense series (2) jquery practice

Source: Internet
Author: User
In practice? Is it too fast? I still don't know how to use JQuery !!... I know what everyone thinks, so rest assured that some things do not require much theoretical knowledge as the basis. In fact, when we have mastered JavaScript, we have mastered JQuery's theoretical knowledge. as mentioned in the Getting Started article, JQuery is actually very simple. :)
Before learning, we recommend that you download JQuery1.3 Chinese reference.
Http://www.jb51.net/books/17812.html

Now, let's go to the topic.JQuery is simple, take easy!

From then on? It's best to start with the ready function!

Definition

Ready (fn );

Function

This is in the event module.Most importantBecause it can greatly improve the response speed of web applications.

Simply put, this method is purely directedWindow. load eventRegister an eventMethod. By using this method, you can call the function you bind immediately when the DOM is ready to read and manipulate, and 99.99% of JavaScript functions need to be executed at that moment.

There is a parameter -- a reference to the jQuery function -- passed to this ready event processing function. You can give this parameter any name, so you can use the $ alias without worrying about name conflicts.

Make sure that the function is not registered in the onload event of the element. Otherwise, the $ (document). ready () event is not triggered.

You can use the $ (document). ready () event infinitely on the same page. The registered functions are executed sequentially.

As described above, we can regard ready as an alternative to onLoad. Some friends will ask, what should we do with the onLoad method?

My personal experience and opinion is that the disadvantage of onLoad is that it will be difficult to maintain it in the future. JavaScript code is everywhere and it is easy to cause problems! In < >, Ppk also views on this issue. Try not to write JavaScript code directly in the tag.

Instance

Two writing methods

I

$ (Document). ready (Function () {alert ("Hello World! ");});

II

Var myFun = function () {alert ("Hello World! ");}

$ (Document). ready (MyFun);

Here I think you should understand the usage of ready, but you should be confused about the previous $ (document). What is this? Don't worry... Now, just remember that the function of this Code is enough to execute the functions in ready after the entire file is loaded.

After reading the following code, we can understand the usage of $.

The code structure of index.html is as follows:




JQuery Testing


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.