The transformation of jquery objects and Dom objects
Only jquery objects can use the method defined by jquery. Note that there is a difference between a DOM object and a jquery object, and the method is invoked with a DOM object or a jquery object in mind.
Ordinary DOM objects can generally be converted to jquery objects by $ ().
Such as:
$ (document.getElementById ("MSG"))
is a jquery object, you can use the jquery method.
Because the jquery object itself is a collection. So if the jquery object is to be converted to a DOM object, one of these items must be removed, which is generally accessible through the index.
Such as:
$ ("#msg") [0],$ ("div"). EQ (1) [0],$ ("div"). get () [1],$ ("TD") [5]
These are DOM objects that can use the methods in the DOM, but no longer use the jquery method.
The following are the correct ways to do this:
$ ("#msg"). html ();
$ ("#msg") [0].innerhtml;
$ ("#msg"). EQ (0) [0].innerhtml;
$ ("#msg"). Get (0). InnerHTML;
In the beginning, the case knows that the original jquery obtained object is not the same object as the object we usually get from using getElementById, since it is not possible to use JavaScript directly in the way that the object obtained through jquery has been used. So some novice is very confused, why ${"#Element"} can not directly innerHTML, this is the reason, the solution please see below.
The transformation of jquery objects and Dom objects
Only jquery objects can use the method defined by jquery. Note that there is a difference between a DOM object and a jquery object, and the method is invoked with a DOM object or a jquery object in mind.
Ordinary DOM objects can generally be converted to jquery objects by $ ().
Such as:
$ (document.getElementById ("MSG"))
is a jquery object, you can use the jquery method.
Because the jquery object itself is a collection. So if the jquery object is to be converted to a DOM object, one of these items must be removed, which is generally accessible through the index.
Such as:
$ ("#msg") [0],$ ("div"). EQ (1) [0],$ ("div"). get () [1],$ ("TD") [5]
These are DOM objects that can use the methods in the DOM, but no longer use the jquery method.
The following are the correct ways to do this:
$ ("#msg"). html ();
$ ("#msg") [0].innerhtml;
$ ("#msg"). EQ (0) [0].innerhtml;
$ ("#msg"). Get (0). InnerHTML;