JQuery Study Notes Learning Notes (i) _jquery

Source: Internet
Author: User
1. Using jquery
To jquery.com download Jquery.js current version is 1.4.2
Create a new HTML page
Copy Code code as follows:

<! DOCTYPE html><br><pre class=brush>   <script type= "Text/javascript" ><BR>    < SPAN style= "color: #ff0000" > $ (document). Ready (function () {</span><br><span style= "color: #ff0000" >       $ ("a"). Click (Function (event) {</span><br><span style= COLOR: #ff0000 ">         alert (" As you can, the link no longer took Jquery.com "); </span><br><span style=" COLOR: #ff0000 ">          Event.preventdefault () </span><br><span style= "COLOR: #ff0000" >       }); </span><br><span style= "COLOR: #ff0000" >    }); </ span><br>     <BR>   </script><br>

Code Explanation:
$ (document). Ready (function () {...}) Add function () content when a page finishes loading
$ ("a"). Click (Function (Event) {...}) Set the Click event function for a label
Event.preventdefault () prevents the original event from executing
Code function: Click <a> tag only pop-up alert information, the page does not jump to http://jquery.com/.
2. Adding and Removing HTML class
First, add a few styles to
Copy Code code as follows:

<style type= "Text/css" >
a.test {font-weight:bold;}
</style>

Use AddClass and Removeclass in script to add and remove HTML class, for example:
Copy Code code as follows:

$ ("a"). AddClass ("test");//All a marked bold
$ ("a"). Removeclass ("test");//Cancel all a marked bold

3. Special effects
jquery offers some very handy effects.
Copy Code code as follows:

$ ("a"). Click (Function (event) {
Event.preventdefault ();
$ (this). Hide ("slow");
});

After clicking on the <a> tag, the tag disappears slowly
4. Callbacks and functions
No parameter callback
Copy Code code as follows:

$.get (' myhtmlpage.html ', mycallback);

Callback with parameter
Copy Code code as follows:

$.get (' myhtmlpage.html ', function () {
Mycallback (param1, param2);
});

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.