[Jquery series] describes Jquery objects and Dom objects, and jquerydom

Source: Internet
Author: User

[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.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.