jquery objects and Dom objects convert fonts to each other: [Increase decrease] Type: Reprint jquery object is the object that is produced after wrapping the DOM object through jquery. jquery objects are unique to jquery and can be used in jquery, but cannot use the DOM method, such as $ ("#img"). attr ("src", "test.jpg"); The $ ("#img") here is the jquery object;
Dom objects are some of the inherent object operations of JavaScript. Dom objects can use JavaScript's inherent methods, but cannot use the methods in jquery. For example: document.getElementById ("img"). src= "Test.jpg"; here the document.getElementById ("img") is the DOM object;
$ ("#img"). attr ("src", "test.jpg"); and document.getElementById ("img"). src= "Test.jpg"; is equivalent, is correct, but $ ("#img"). src= "Test.jpg" or document.getElementById ("img"). attr ("src", "test.jpg"); are all wrong.
In an example: this is what I often write about when I write jquery: this.attr ("src", "test.jpg"); But it was a mistake. This is actually a DOM object, and. attr ("src", "test.jpg") is the jquery method, so something went wrong. To solve this problem, convert the DOM object to a jquery object, such as $ (this). attr ("src", "test.jpg");
The 1.DOM object is converted to a jquery object:
For a DOM object, you can just wrap the DOM object with $ () and you'll get a jquery object. $ (DOM object)
such as: Var V=document.getelementbyid ("V"); Dom Object
var $v =$ (v); jquery Object
After the conversion, you can use the JQuery method arbitrarily.
The 2.jQuery object is turned into a DOM object:
Two conversions convert a jquery object to a DOM object: [index] and. get (index);
(1) JQuery object is a data object, you can get the corresponding Dom object by means of [index].
such as: Var $v =$ ("#v"); jquery Object
var v= $v [0]; Dom Object
Alert (v.checked)//Detect if this checkbox is selected
(2) jquery itself provides, through the. Get (Index) method, to get the corresponding DOM object
such as: Var $v =$ ("#v"); jquery Object
var v= $v. Get (0); Dom Object
Alert (v.checked)//Detect if this checkbox is selected
jquery objects are not DOM objects