Mutual conversion between jQuery objects and DOM objects
Source: Internet
Author: User
1. Define jQuery as follows: var $ variablejQuery object; DOM object definition: varvariableDOM object; 2. Converting jQuery object to DOM object jQuery object cannot use DOM object method. JQuery has two methods to define a jQu... SyntaxHighlighter. 1.
JQuery is defined as follows:
Var $ variable = jQuery object;
DOM objects are defined as follows:
Var variable = DOM object;
2. convert a jQuery object to a DOM object
JQuery objects cannot use DOM objects.
JQuery has two methods to convert a jQuery object to a DOM object: [index] And get (index)
(1) [index]
Var $ variable = $ ("# con"); // jQuery object
Var dom = $ variable [0]; // convert to a DOM object
(2) get (index)
Var $ variable = $ ("# con"); // jQuery object
Var dom = $ variable. get (0); // convert to a DOM object
3. convert a DOM object to a jQuery object
The jQuery object method cannot be used in DOM objects.
Var dom = document. getElementById ('Con '); // DOM object
Var $ variable = $ (dom); // convert to jQuery object
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service