This article mainly introduces jQuery's methods for obtaining DOM nodes. It provides two methods for jQuery to obtain DOM nodes. For more information, see the following example. We will share this with you for your reference. The details are as follows:
The DOM object wrapped in jQuery is actually an array. There are two ways to obtain a pure DOM object:
1. Access through array IndexesFor example:
The Code is as follows:
Var dom = $ (dom) [0];
2. Use the get () function to accessFor example:
The Code is as follows:
Var dom = $ (dom). get (0 );
The parameter in the get () function is the index number.
3. Example
Var p = document. createElement ("DIV"); p. innerText = "test is OK! "; Document. body. appendChild (p); var $ tmp = $ (p); alert ($ tmp [0]. innerText); // method 1 gets the DOM Node object alert ($ tmp. get (0 ). innerText); // method 2 get the DOM Node object
I hope this article will help you with jQuery programming.