JQuery and dom objects in javascript, jquerydom

Source: Internet
Author: User

JQuery and dom objects in javascript, jquerydom

1. a dom object belongs to the Document Object Model, while a Query object encapsulates one or more dom objects. Therefore, dom objects can be considered as one entity, jQuery looks at the collection of multiple dom objects.

2. jQuery and dom do not contain or are contained. Therefore, jQuery objects cannot call dom methods or attributes. Similarly, dom,

{($ ("# Swap"). innerHTML = "embedded text"

GetElementById ("wrap" ).html ('embedded text ')

.

3. jQuery and dom objects can be converted to each other. Because of this, a common method is to capture an object through dom and then archive it as a jQuery object, the reason is that the jQuery object does not need to be traversed when no operation is required.

4. jQuery object and dom object Conversion Method

Convert jQuery to a dom object

{

Var $ li = $ ("li ");

Var li = $ li [0];

Li. innerHTML;

}

{

Var $ li = $ ("li ");

Var li = $ li. get (0); // call the domget Method

Alert (li. innerHTML );

}

Convert a dom object to a jQuery object

{

Var li = getElementById ('lil'); // obtain all li Elements

Var $ li = $ (li); // encapsulate the obtained li element into a jQuery object.

Alert($li.html ());

}

Related Article

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.