Learning JQuery objects step by step (1) JQuery objects step by step

Source: Internet
Author: User

Learning JQuery objects step by step (1) JQuery objects step by step
JQuery is another excellent JavaScript library after Prototype
JQuery philosophy:Write less and do more. Advantages:
Lightweight
Powerful Selector
Excellent DOM operation Encapsulation
Reliable Event Processing Mechanism
Comprehensive Ajax
Excellent browser compatibility

Chain Operation Method

Create static Web Project under Eclipse, import jquery-1.9.1.js

JQuery: Hello World

<Html> 

1. JQuery object

A jQuery object is an object generated after DOM objects are packaged using jQuery ($ ().
JQuery objects are exclusive to jQuery. If an object is a jQuery object, it can use the method in jQuery: Getting ({{persontab}}.html ();
JQuery objects cannot use any methods of DOM objects. Similarly, DOM objects cannot use any methods in jQuery.
Convention: If you get a jQuery object, add $ before the variable.
Var $ variable = jQuery object
Var variable = DOM object

1.1 convert a jQuery object to a DOM object

JQuery objects cannot use methods in the DOM, but if jQuery does not encapsulate the desired method, there are two ways to deal with DOM objects:

(1) The jQuery object is an array object. You can use the [index] method to obtain the corresponding DOM object.


(2) Use the get (index) method in jQuery to obtain the corresponding DOM object.


<! DOCTYPE html> 

1.2 convert a DOM object to a jQuery object

For a DOM object, you only need to use $ () to wrap the DOM object (jQuery object is the object generated after DOM object is wrapped through jQuery) to obtain a jQuery object.


After conversion, you can use the method in jQuery.

<Html> 



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.