1. convert a DOM object to a jquery object:
Convert a jquery object to a DOM object:
Two conversion methods are used to convert a jquery object to a DOM object: [Index] And. Get (INDEX );
(1) The jquery object is a data object. You can use the [Index] method to obtain the corresponding DOM object.
For example, VAR $ v = $ ("# V"); // jquery object
VaR v = $ V [0]; // DOM object
Alert (V. Checked) // checks whether the checkbox is selected
(2) jquery provides the. Get (INDEX) method to obtain the corresponding DOM object.
For example, VAR $ v = $ ("# V"); // jquery object
VaR v = $ v. Get (0); // DOM object
Alert (V. Checked) // checks whether the checkbox is selected
Convert a DOM object to a jquery object:
For a DOM object, you only need to wrap the DOM object with $ () to obtain a jquery object. $ (DOM object)
For example, VAR v = Document. getelementbyid ("v"); // DOM object
VaR $ v = $ (V); // jquery object
After conversion, you can use the jquery method at will.
Bytes -------------------------------------------------------------------------------------------
For a DOM object, you only need to wrap the DOM object with $ () to obtain a jquery object. $ (DOM object)
For example, VAR
V = Document. getelementbyid ("v"); // DOM object
VaR $ v = $ (V); // jquery object
After conversion, you can use the jquery method at will.
2. convert a jquery object to a DOM object:
Two conversion methods are used to convert a jquery object to a DOM object: [Index] And. Get (INDEX );
(1) The jquery object is a data object. You can use the [Index] method to obtain the corresponding DOM object.
For example, VAR $ v = $ ("# V ")
; // Jquery object
VaR v = $ V [0]; // DOM object
Alert (V. Checked)
// Check whether the checkbox is selected
(2) jquery provides the. Get (INDEX) method to obtain the corresponding DOM object.
For example, VAR $ v = $ ("# V"); // jquery object
VaR v = $ v. Get (0); // DOM object
Alert (V. Checked) // checks whether the checkbox is selected
the preceding method allows you to convert jquery objects and DOM objects to each other. Note that DOM objects can use methods in Dom. jquery objects cannot use methods in Dom.