Dom conversion element with Jquery

(. 1) jQuery object into a DOM objects:
two conversion mode to convert a DOM object jQuery object: [index] and .get (index);
jQuery object is a data object, by [index] method, to obtain a respective DOM object.
Such as:

var $v =$("#v") ; //jQuery对象
var v=$v[0]; //DOM对象
alert(v.checked) //检测这个checkbox是否被选中

jQuery itself provided by .get (index) method, to give the corresponding DOM object
, such as:

var $v=$("#v"); //jQuery对象
var v=$v.get(0); //DOM对象
alert(v.checked) //检测这个checkbox是否被选中

 

(2) DOM object into a jQuery object:
to have a DOM object, just use the $ () to wrap up the DOM object, you can get a jQuery object up. $ (DOM objects)
such as:

var v=document.getElementById("v"); //DOM对象
var $v=$(v); //jQuery对象

 

Published 327 original articles · won praise 566 · Views 2.63 million +

Guess you like

Origin blog.csdn.net/vtopqx/article/details/89082916