DOM object to JQuery object

$div = $div(‘ id ‘); $div [index]; $div [index]; $div [index]; $div [0].get(index); (3) Directly manipulate attributes through DOM.

DOM objects are converted to jQuery objects

Next DOM – >JQuery passes $(parameter)

Development is more about processing a DOM object into a jQuery object than jQuery into a DOM. $(parameter) is a multifunctional method that does different things by passing different parameters.

If the argument passed to the $(DOM) function is a DOM object, the jQuery method wraps the DOM object into a new jQuery objectCopy the code

(1) getElementsByTagName(‘ div ‘); Get the DOM elements of all div nodes. This is a DOM collection. (2) Convert the DOM collection into JQuery objects with $(parameter). CSS (‘ color ‘, ‘read’); CSS (‘ color ‘, ‘read’); Sets the color of the JQuery object

<script type="text/javascript"> // Get all div node elements by getElementsByTagName(xx), Note that the result is a collection of DOM var tmpDom = document. The getElementsByTagName (' div '); Var $div = $(tmpDom); Var $first = $div.fisrt(); $first.css('color', 'red'); // Set the color </script>Copy the code