Getting Started with jquery

Source: Internet
Author: User

Getting Started with jquery

before learning jquery, look at HTML, CSS, JavaScript.

jquery is a library of JavaScript functions

Mainly include:

1.HTML element Extraction

2.HTML element operation

3.CSS operation

4.JavaScript Effects and animations

5.HTML DOM Traversal and modification

6.AJAX

7.Utilities

First, how to use jquery in HTML

Add a script tag to the head in the page

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

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

Second, the most distinctive features of jquery

$ is one of the obvious features of jquery. Its basic usage: $ (selector). Action ()

(1) selector a bit like DOM parsing.

(2) Action is the response event.

Third, jquery selector

(1) using CSS to extract HTML elements

Extract tags for all "p" in HTML: $ ("P")

Extract the label for "P" in a class in HTML: $ ("P.class")

Extract the first tag with "P" in the HTML ID as Demo: # ("P#demo")

(2) using XPath to extract the elements of a given property

$ ("[href]") selects all elements with an href attribute.

$ ("[href= ' # ']") selects all elements with an HREF value equal to "#".

$ ("[href!= ' # ']") selects all elements with an HREF value that is not equal to "#".

$ ("[href$= '. jpg ']") selects all elements with an href value ending with ". jpg".

Iv. Responding to Events

$ ("label"). Click (function () {... some code ...})

(1) in the head of the HTML

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

<script type= "Text/javascript" >

$ (document). Ready (function () {

$ ("button"). Click (function () {

... some code ...

 });

});

</script>

(2) in a separate JS

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

<script type= "Text/javascript" src= "My_jquery_functions.js" ></script>

Note: jquery name conflicts

jquery uses the $ symbol as a way to profile jquery.

functions in some other JavaScript libraries, such as Prototype, also use the $ notation.

JQuery uses a method called noconflict () to resolve the problem.

var jq=jquery.noconflict (), which helps you to use your own name (such as JQ) instead of the $ symbol.

V. Event functions

Common events: Hide, show, toggle, swipe, and animate


Getting Started with jquery

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