If you get an object that is a jquery object, add $ before the variable, for example:
The
code is as follows:
var $variable = jquery object;
If you get a DOM object, it is defined as follows:
The
code is as follows:
var variable = dom object;
jquery objects cannot use methods in the DOM, but if you are unfamiliar with the methods provided by the JQuery object, or if jquery does not encapsulate the methods you want, and you have to practice DOM objects, there are two ways to do this. jquery provides two ways to convert a jquery object into a DOM object, that is, [index] and get (index).
1. The jquery object is an array object, and the corresponding DOM object can be obtained by means of [index].
The
code is as follows:
var $CR = $ ("#cr"); jquery Object
var cr = $CR [0]//dom Object
alert (cr.checked)//Detect if the checkbox is selected
2, the corresponding DOM object is obtained by Get (index) method.
The
code is as follows:
var $CR = $ ("#cr");
var cr = $cr. Get (0);
alert (cr.checked);
For a DOM object, it takes $ () to wrap the DOM object in order to get a jquery object, in the form of $ (DOM object).
The
code is as follows:
var cr = document.getElementById ("Cr"); Dom Object
var $CR = $ (CR);
Summarize:
The Get method in the JQuery method is in fact getting the DOM element ($ (this). Gets (0) and $ (this) [0])
The EQ, the top and the last methods in the JQuery method are all the jquery objects that are returned
Third, Dom objects can use methods in the DOM, and jquery objects cannot use methods in the DOM. The jquery object provides a more complete set of tools for manipulating the DOM.