Home  >  Article  >  Web Front-end  >  What is the difference between dom and jquery objects

What is the difference between dom and jquery objects

青灯夜游
青灯夜游Original
2021-11-15 16:36:164481browse

Difference: 1. The DOM object is an object returned by using the JavaScript method to get the elements in the page, while the jquery object is the object returned by using the jquery method to get the elements in the page; 2. The DOM object can only access the predefined ones in the DOM Methods, jquery objects can only call methods provided by jQuery.

What is the difference between dom and jquery objects

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

Dom object

The Document Object Model, referred to as DOM, is a standard programming interface for processing extensible markup languages ​​recommended by the W3C organization.

  • DOM is actually a document model described in an object-oriented manner. The DOM defines the objects required to represent and modify a document, the behaviors and properties of these objects, and the relationships between these objects.

  • Through the DOM, you can access all HTML elements, along with the text and attributes they contain. The content can be modified and deleted, and new elements can also be created.

  • DOM is platform and programming language independent. It can be used by any programming language such as Java, JavaScript and VBScript.

  • DOM object is the object we obtain using traditional methods (javascript).

  • DOM is precisely a specification standard for document objects (Document Object Model). The standard only defines properties and method behaviors.

jQuery object

The jQuery object is actually a JavaScript array. This array object contains 125 methods and 4 The four attributes

are:

  • jquery The current jquery framework version number

  • length indicates the array object The number of elements.

  • context generally points to the HtmlDocument object.

  • selector The passed in selector content

The jquery object is an object generated by wrapping the DOM object through jQuery. The jQuery object is unique to jQuery. It can use methods in jQuery, but cannot use DOM methods; conversely, Dom objects cannot use jquery methods.

The difference between jQuery objects and DOM objects

1. Different definitions

DOM objects: The object returned by using methods in JavaScript to obtain elements in the page is a DOM object, and methods defined by jquery cannot be used.

var dom-elem = document.getElementById("msg")

jQuery object: The jquery object is to use the jquery method to obtain the elements in the page. The returned object is the jQuery object. You can use the methods defined by jquery.

var jquery-elem = $("#msg")

2. Obtaining different

DOM objects is document.getElement to obtain the dom object. The DOM object can only access the predefined ones in the DOM. method.

The jQuery object is the object returned by $() object processing. The object is an array of jQuery and can only call the methods provided by jQueryr.

For more programming-related knowledge, please visit: Introduction to Programming! !

The above is the detailed content of What is the difference between dom and jquery objects. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn