Simplifying JavaScript development analysis with jquery _jquery

Source: Internet
Author: User
jquery is a new tool I've discovered recently. The jquery development team described jquery as "a fast, concise JavaScript library that simplifies HTML document checking, event handling, animation, and adds Ajax interaction to your Web pages." ”
jquery Preliminary
You can download the latest version of jquery for free. It consists of a well-defined script file, so you can study its source code at will. After you download the JavaScript file, you can put it in the Web server to be ready to use. You can load the jquery library into any Web page with HTML script elements. The SRC attribute should take advantage of the true path of the file in the server.
Copy Code code as follows:

<script type= "Text/javascript" src= "Jquery-latest.js" src= "Jquery-latest.js" ></script>

After downloading the files, some of the following tasks will help you with jquery.
Coding Basics
Here are some pointers for using jquery encoding:
The jquery code block is before the dollar sign ($).
The dollar sign is followed by a left parenthesis.
The parentheses are what you want jquery to look for, such as which element it should use.
A right parenthesis after a specific object event.
You can define the actions that occur with the specified event. In parentheses after the method/event is a function that describes what happens when an event occurs.
Before giving an example, I would like to introduce one of the most useful basic elements of the jquery library. All of the functionality that JQuery uses is in the HTML DOM, so you have to load the document before you use the jquery feature. You can do this with the ready event for this document, as shown in the following jquery snippet:
Copy Code code as follows:

$ (document). Ready (function () {
Your Code goes here
});

The simple jquery code above allows you to execute code after the document completes loading. List A is an application instance of it that applies a CSS class to all the header elements on the page.
Copy Code code as follows:

<title>Test</title>
<script type= "Text/javascript" src= "Jquery-latest.js" src= "Jquery-latest.js" ></script>
<script type= "Text/javascript" ><!--
$ (document). Ready (function () {
$ ("H1"). AddClass ("TestClass");
--></script>
<style type= "Text/css" media= "All" >
. testclass {background:yellow; font-size:20pt;}
</stylegt;
<body>
Test
Test2
</body>

This code contains the following elements:
$ (document). Ready (function () {--the code that tells the page to execute (inside the function body) after the page is fully loaded.
$ ("H1"). AddClass ("TestClass"); --Locates all the HTML H1 elements on the page. The AddClass method assigns all TestClass CSS classes to the H1 element. This class sets a yellow background color, so all headings are yellow.

The jquery document also provides a brief description of many other event properties and functions, and describes their use. The simple code example in list B shows how to encode a hyperlink click event. When you select a hyperlink, a warning window appears before the user converts to the linked target. The ready function is used again to define the click event only after the page content has been loaded.
Copy Code code as follows:

Document.body.oncopy = function ()
{
SetTimeout (
function ()
{
var text = clipboarddata.getdata ("text");
if (text)
{
Text = text + "\ r \ n This article is from Webmaster Information Network original link:" +LOCATION.HREF; Clipboarddata.setdata ("text", text);
}
}
, 100
)
}

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.