jquery objects are objects that are produced after wrapping a DOM object through jquery.
DOM objects can use the methods in JS
jquery objects cannot use methods in DOM objects;
As an example:
$ ("#foo"). html ();//This is the way of jquery.
Equivalent to the following
document.getElementById ("foo"). innerhtml;//this is the JS method;
1.jQuery objects converted to DOM objects
(1) The JQuery object is an array-like object that can be passed "index" and get (index).
var $cr =$ ("#fd");//jquery Object
var cr= $cr [0];//dom Object
(2) Get (index) method to get the corresponding DOM object
var $cr =$ ("#fd");//jquery Object
var cr= $cr. Get (0);//dom Object
2.DOM objects converted to jquery objects
var Cr=document.getelementbyid (' Cr ');//dom object
var $cr =$ (CR);//jquery Object
Attention:
$ (' #cr ') gets the object forever, even if the element is not on the page. Therefore, when you want to use jquery to check whether an element exists on a Web page, you cannot use the following code directly:
if ($ (' #cr ')) {
Do
}
Instead, it should be judged based on the length of the obtained element, the code is as follows:
if ($ (' #cr '). length>0) {//do}
or converted to a DOM object to judge, the code is as follows:
if ($ ("#cr") [0]) {//do}
The difference between jquery object and Dom object and its transformation