Dom objects and jquery wrapper sets

Source: Internet
Author: User

Dom Object

In traditional JavaScript development, we are often the first to get DOM objects, such as:

document.getElementById ("Dv1");

We often use the getElementById method to get DOM objects. In the event trigger function, we can also get the reference event trigger object through this. Or, We can also get the DOM object that raised the event by Event.target or Event.srcelement.

Note that here we get all the DOM objects.

jquery Package Set

The jquery wrapper set can be said to be an extension of the DOM object. In the world of jquery, all objects, whether one or a group, are encapsulated into a jquery package set.

For example, get a jquery package set that contains an element:

var jqueryobject = $ ("#dv1");

The jquery wrapper set is called together as an object, and the jquery wrapper has a rich set of properties and methods that are unique to jquery.

Conversion of Dom objects to jquery objects

(1) Dom object converted to jquery wrapper set

Way One//      use the function provided by jquery Yvar Jqueryobject = $ ("#dv1");//Method two//      first Get DOM object//      and then use the function provided by jquery to wrap var dom_dv1 = document.getElementById ("Dv1"); var jQueryObject2 = $ (DOM_DV1);

(2) jquery wrapper set converted to DOM object

Execute the following code:

var jqueryobject = $ ("#dv1");d Ebugger;

In the process of debugging, we look at jqueryobject[0], we will find that the ID of this property is Dv1, is exactly what we need DOM object

Defining the concepts of DOM objects and jquery packaging sets will speed up our learning and avoid detours.

Dom objects and jquery wrapper sets

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.