jquery objects and JavaScript objects that are DOM objects are converted to each other
1. DOM object into JQuery object
For a DOM object, you just need to wrap the DOM object with $ () and you can get a JQuery object, $ (DOM object) Note: VAR is a variable defined
Such as:
var v = document.getElementById ("V"); /dom object
var $v = $ (v);//jquery Object
After conversion, you can use JQuery in any way.
2. JQuery objects into DOM objects
Two ways to convert a jQuery Objects into DOM objects: [index] and. get (index);
(1) The JQuery object is a data object that can be used by the [index] method, To get the corresponding DOM object.
var $v = $ ("#v");//jquery Object
var v = $v [0] ; DOM object
alert ( v.checked); Detects whether the checkbox is selected
(2) The jQuery itself is provided by the. Get (index) method to get the corresponding DOM object
example:
var $v = $ ("#v"); JQuery Object
var v = $v. Get (0); Dom Object ($v. get () [0] can also)
alert (v.checked); Detects if the checkbox is selected
jquery objects and JavaScript objects that are DOM objects are converted to each other