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>