The difference between a DOM object and a JS object and a jquery object

Source: Internet
Author: User

The difference between a DOM object and a JS object and a jquery object

One, Dom object

The Document Object model, referred to as DOM, is the standard programming interface recommended by the Organization for the processing of extensible superscript languages.

  1. The DOM is actually a document model that is described in an object-oriented manner. The DOM defines the objects that are required to represent and modify the document, the behavior and properties of those objects, and the relationships between those objects.
  2. Through the DOM, you can access all the HTML elements, along with the text and attributes they contain. You can modify and delete the content, and you can also create new elements. Html
  3. The DOM is independent of the platform and programming language. It can be used by any programming language such as Java, JavaScript, and VBScript.
  4. Dom objects, which are the objects we get with traditional methods (JavaScript).
  5. The DOM is exactly a normative standard (Document Object model) for document objects, and the standard defines only properties and method behavior. Second, JavaScript objects
    1. JavaScript provides multiple built-in objects, such as String, Date, Array, and so on.
    2. Objects are just special data types with properties and methods.
    3. The DOM object obtained by JS is the JS object.
    4. When the browser supports JS DOM interface (API), here the narrow Dom object is in the form of a JS object, that is, a JS object
    Third, jquery object
      1. The jquery object is actually an array of JavaScript, which contains 125 methods and 4 properties
        4 properties, respectively, are

        • jquery Current jquery Framework version number
        • Length indicates the number of elements of the array object.
        • The context is generally directed to the HTMLDocument object.
        • Selector passed in selector content

        The jquery object is the object that is generated after wrapping the DOM object through jquery. jquery objects are unique to jquery and can be used in jquery, but not in the DOM, which in turn cannot be used by the DOM object.

      2. The jquery object differs from the JS object:
        1.jQuery object belongs to JS array;
        2.jQuery objects are generated after a DOM object wrapped in jquery;
        3.jQuery objects cannot use methods and properties of DOM objects
        4.DOM objects cannot use the methods and properties of jquery objects

      3. Mutual conversions between jquery objects and JS objects

1) JS to jquery object:

$ (JS object)

2) JQuery object to JS object

Example:

Convert a jquery object to a DOM object

Doc2.innerhtml= "This is the first DOM object of jquery"

Use the Get function provided by the JQuery object itself to return the DOM object at the specified collection location

var doc2=$ ("#idDoc2"). Get (0);

Doc2.innerhtml= "This is the second DOM object of jquery"

The difference between a DOM object and a JS object and a jquery object

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.