The DOM operation of jquery

Source: Internet
Author: User

How much do we know about Dom's cognition?

The DOM is the abbreviation of Document Object model, which means that the documentation objects are the standard of a set of documents for accessing and manipulating XML (extensible Markup Language), the API, developed by the consortium. For example, the DOM tells the JavaScript engine how to display and manipulate XML-created markup (tag) in a browser window. The DOM is a browser-, platform-and language-agnostic interface that makes it easy to access all the standard components in a page, according to the Web DOM specification. In a nutshell, Dom solves the conflict between Netscape's JavaScript and Microsoft's JScript, giving web designers and developers a standard way to easily get and manipulate data, scripts, and presentation-level objects in a Web page.

XML is similar to HTML, but there is a difference between the two. Both XML and HTML come from SGML, and they all contain tags, with similar syntax, and the biggest difference between HTML and XML is that HTML is a trained markup language that describes and displays data with fixed tags, such as

Because of the similarities and differences between HTML and XML, JavaScript not only implements standard DOM methods and properties (i.e., created by the universe), but also implements HTML-specific DOM methods and properties, formerly known as Dom Core, and not specifically JavaScript. The latter is called Html-dom. Whether it's DOM core or html-dom, we should be aware of the compatibility between browsers when using JavaScript, because different browsers might not support these two types of methods and properties. DOM core and Html-dom, as well as cross-browser compatibility, are described in detail in the textbook. However, it is generally recommended to use the DOM core methods and properties, albeit slightly cumbersome.

In general, DOM operations are divided into 3 areas, Dom core (core), Html-dom, and Css-dom.

DOM Core

Dom core is not specific to JavaScript, and it can be used by any programming language that supports the DOM. Its purpose is not only to process Web pages, but also to handle any document written in markup language, such as XML.

Methods such as Getelmentbyld (), getElementsByTagName (), getattribute (), and setattribute () in JavaScript are all part of the DOM core.

For example:

Ways to get Form objects using DOM core:

document.getElementsByTagName ("form");

To get the SRC attribute of an element using the DOM core method:

Element.getattribute ("src");

When scripting HTML files using JavaScript and DOM, there are many attributes that are specifically html-dom. The advent of html-dom is even earlier than Dom core, which provides some more concise notation to describe the attributes of various HTML elements.

Html-dom

For example:

Ways to get Form objects using Html-dom:

Document.forms  //html-dom provides a Forms object

To get the SRC attribute of an element using Html-dom:

ELEMENT.SRC;

Using the method described above, you can find that getting some objects, properties can be implemented either with Dom core or html-dom. In contrast, html-dom code is usually short, but it can only be used to work with Web documents.

Css-dom

Css-dom is a CSS-specific operation. In JavaScript, the main function of Css-dom technology is to get and set various properties of a style object. By changing the various properties of the style object, you can make the Web page appear in a variety of different effects.

For example, to set the font color of an element's style object:

Element.style.color = "Blue";

The DOM operation of jquery

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.