jquery Learning Summary "one" _jquery

Source: Internet
Author: User

jquery Learning Summary "one"

One: JQuery

1 jquery Knowledge

*: That is, let us learn to call JQ Plug-ins, in fact, the internal is the package JS.

There are three files inside the *:jquery,

The 2nd and 3rd contents are the same, but the third one compresses them, making the browser's access time shorter.

We put Jquery-1.4.2.js and jquery.1.4.2-vsdoc,js together in use, in fact vsdoc.js is for the previous explanation, it is let us write the code can point operation out.

*: Practice "click on the Button pop-up dialog box" "Click the text inside the page to make the text line disappears" ("$" This is actually a function)

 
 

2 jquery inside the ready "at the beginning of the page to pop-up content"

$(dounction).ready(function(){alert(“加载完毕”);})

I can actually write this.

$(function(){alert(“加载完毕”);});

< resolution: "$" This function registers the anonymous function function () as ready execution. >

3 jquery built-in functions

Each element in the array in the. Map (ARRAY,FN) is invoked to handle the FN function, the FN function returns, and finally a new array is called. The FN function is invoked for each element of the array in the. Map (ARRAY,FN). The FN function returns the processing and finally gets a new array. The map cannot handle dictionary-style arrays. Use the following $.each to process.

The $.each (ARRAY.FN) array arr Each element invokes the FN function for processing, with no return value.

var arr=[3,5,7]; 
Var arr2= $map. (Arr,function (item) {return ITEM*2}) functional programming. 
Var arr={"Tom"; Sandalwood "," Xiaozhang; " Small Zhang "} 
$.each (Arr,function (key,value) {alert (key+" = "+value);});

4 jquery objects, DOM objects

<dom is the browser's some tags, such as layers, buttons, tags, etc., the array is JQ object. >

The jquery object is created after the DOM object is wrapped in jquery. and jquery objects can only invoke methods encapsulated by jquery objects. Methods of Dom objects cannot be called.

$(function(){$(“#id”).css(“background”,”red”)});

The above code is copied, that is, the background color set to red, if the. css in the property is one to get the value, 2 is the set value.

5 jquery Selector

*id Selector

$(“#div”).html();

*tabname Selector < Tag Selector >

$(“div”).click(function(){alert(“你好我是p”);});

This is where all the div tags in the page are selected, and the Click event is added to it.

* CSS Selector

Selecting multiple styles at the same time is an addition to the styling.

$(“div”).click(function(){alert(“这是信息”)});

More than 6 pieces selector/Hierarchy Selector

7 Iteration of jquery

Is inside the error program does not give a hint error, we want to add if/elae statement to judge.

8 jquery Node Traversal

is to use the next (), Nextall () method to traverse.  It's like the traversal in the array is the same. Here just gets the value of its next element.

Siblings (): Gets the sibling element (sibling node) of all elements.

*:jquery-Chained programming

$ ("div"). Click (function () {
$ (this). CSS ("Background", "Red"). Siblings ("div"). CSS ("Background", "White")
} );

It is easy to operate through the dot operator.

This is a chain operation, reducing the use of if/else and other operations. Changed the programming style.

<! DOCTYPE html>
 
 

9: The basic filter

This can be written together, such as selectors and filters, which is very powerful.

Not only can you use the selector for absolute positioning, you can also position relative, as long as you specify the second argument in $ (), and the second parameter is the relative element.

Case:

(relative positioning)

: The element here is the location of the TD under Location #tables TR

10 Property Filter

Eg:

<! DOCTYPE html>
 
 

Each of the 11 elements is traversed by a number of filters and selectors to each of the elements of each <. >

<! DOCTYPE html>
 
 

Above is the entire content of this article, I hope to help you, the next article continues to introduce jquery basic knowledge--jquery Learning Summary "Two", interested friends can see. Thanks for the support of the cloud-dwelling community!

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.