[Jquery series] describes Jquery objects and Dom objects, and jquerydom
Problem description
This article describes Jquery objects and DOM objects in the following five aspects:
- Jquery object and dom object definition
- Differences between Jquery objects and dom objects
- Jquery objects and Examples
- Dom objects and Examples
- Conversion between Jquery objects and dom objects
1 content area
1.1 Jquery object and dom object definition
JQuery object: Jquery object, the object obtained through the jq selector;
Dom object: javascript Object, that is, the object obtained through js;
1.2 differences between Jquery objects and dom objects
A jquery object is an object obtained using the jquery selector. The format is $ (selector );
Dom objects refer to objects obtained through the original sound source js, such as document. getElementById ();
1.3 Jquery objects and Examples
Var $ obj = $ ("# id"); // jQuery object
1.4 dom objects and Examples
Var DomObj = document. getElementById ("id"); // dom object
1.5 conversion between Jquery objects and dom objects
Callback (), the dom object must be converted to a jq object before calling it. Otherwise, an error occurs (jq calls dom in the same way );
1.5.1 converting a jquery object to a dom object
Jquery provides two methods to convert a jquery object into a dom object, that is, [index] And get (index ).
Var JqObj = $ ("# id"); // jquery object var DomObj = JqObj [0]; // dom object // The following can also be written as var DomObj = JqObj. get (0); alert (DomObj. checked); // check whether checkbox is selected
1.5.2 convert a dom object to a jquery object
For dom objects, use $ () to wrap the dom object in the format of $ (dom object );
Var DomObj = document. getElementById ("ElementID"); // dom object
Var JqObj = $ (DomObj); // convert to jquery object
2. Copyright Zone
- Thank you for your reading. If you have any shortcomings, please kindly advise and learn and make progress together.
- Blog website: http://www.cnblogs.com/wangjiming /.
- A small number of articles are integrated by reading, referencing, referencing, copying, copying, and pasting. Most of them are original articles.
- If you like, please recommend it; if you have new ideas, welcome to raise, mailbox: 2016177728@qq.com.
- This blog can be reposted, but it must be a famous blog source.