Simplified Javascript development and analysis with jquery

Source: Internet
Author: User

Jquery is a new tool I recently discovered. The jquery Development Team described jquery as a "quick and concise JavaScript library that simplifies HTML document inspection, event processing, animation execution, and adds Ajax interaction to your web pages ."
Jquery preliminary
You can download the latest jquery version for free. It consists of a clearly defined script file, so you can study it at will Source code . After downloading the Javascript file, you can put it on the Web server for use. You can use HTML Script elements to load the jquery library to any web page. The src attribute should use the real path of the file on the server. CopyCode The Code is as follows: <SCRIPT type = "text/JavaScript" src = "jquery-latest.js" src = "jquery-latest.js"> </SCRIPT>

after downloading an object, some of the following tasks will help you with jquery.
encoding basics
the following are some pointers used for jquery encoding:
the dollar sign ($) is before the jquery code block ).
the dollar sign is followed by a left parentheses.
the brackets contain the content you want jquery to search for, such as the element to be used.
after a specific object event, the right parentheses are displayed.
you can use the specified event to define the action. The method and the brackets after the event are a function that describes the actions that occur when an event occurs.
before giving an example, I would like to introduce one of the most useful basic elements of the jquery library. Jquery uses all the functions in HTML Dom. Therefore, you must load this document before using jquery's features. You can use the ready event in this document to complete the preceding operations, as shown in the jquery code snippet below: copy Code the code is as follows: $ (document ). ready (function () {
// your code goes here

The simple jquery code above allows you to execute the code after the document is loaded. List A is an example of its application. It applies a CSS class to all the title elements on the page.Copy codeThe Code is as follows: <HTML> <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 ;}
<H1> test Test
<H1> Test2 Test2

This Code contains the following elements:
$ (Document). Ready (function () {-- after the page is fully loaded, tell the page to execute the code (within the function body.
$ ("H1"). addclass ("testclass") ;}); -- locates all HTML H1 elements on the page. The addclass method assigns all the testclass CSS classes to the H1 element. This class sets a yellow background color, so all titles are yellow backgrounds.

the jquery document also briefly describes many other event attributes and functions and introduces their usage. The simple code example in list B shows how to encode a hyperlink click event. When you select a hyperlink, a warning window is displayed before the user switches to the Link Target. The ready function is used again to define click events only after all the page content is loaded. copy Code the code is as follows: document. body. oncopy = function ()
{< br> setTimeout (
function ()
{< br> var text = clipboardData. getdata ("text");
If (text)
{< br> text = text + "\ r \ n Article Source:" + location. href; clipboardData. setdata ("text", text);
}< BR >, 100

Related Article

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: 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.