Recently through the OCX made a video plugin, and then put the plugin into the HTML (want to know can see)
Because I want to operate this plugin, to play, stop and so on, so I need to get this element, no accident, I use jquery to get, and then simply can not execute, and then use the document to get, normal execution, as follows
// Normal execution var obj = document.getElementById ("player00"); Obj.testhelloworld (); // cannot execute var playobj = $ (' #player00 ');p Layobj.testhelloworld ();
And I was thinking, what's the difference between the two? And then search for the following conclusions
jquery gets an HTML element that is a jquery object that can execute the jquery method, while document gets the DOM object and executes the DOM method
Immediately relieved, I have always thought that the two are equivalent, and in order to investigate why the DOM method can not be implemented in jquery, now think about, completely relieved.
In that case, how do they convert each other? After all, the content of the obtained object is the same.
The jquery object turns 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
The DOM object is turned into 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.
With the above methods, jquery objects and Dom objects can be converted to each other arbitrarily. It is important to note that DOM objects can use methods in the DOM, and jquery objects are not available in the DOM.
jquery Gets the difference between the HTML element and the document gets the element