Implementation of DOM operations in jQuery. For more information about DOM operations, see. DOM is divided into three aspects, namely DOM Core, HTML-DOM, CSS-DOM.
1. DOM Core is not specialized in JavaScript. It can be used by any programming language that supports DOM.
GetElementById (), getElementsByTagName ()... and other methods in JavaScript.
For example, you can use DOM Core to obtain form objects:
Document. getElementsByTagName ("form ");
2, HTML-DOM.
When using JavaScript and DOM to write scripts for HTML files. there are many properties dedicated to HTML-DOM. the appearance of HTML-DOM is even earlier than DOM Core, which provides more concise marks to describe the attributes of various HTML elements.
For example, the way to get form objects using a HTML-DOM:
Document. forms // The HTML-DOM provides a forms object.
3, CSS-DOM
CSS-DOM is the operation for CSS. In JavaScript, CSS-DOM technology is mainly used to obtain and set various attributes of style objects.
For example, you can set the font color of an element style object: element. style. color = "red ";
The following describes the DOM operations in jQuery:
First construct a DOM tree:
The Code is as follows:
DOM operations in jQuery
What is your favorite fruit?
The subsequent operations are centered around the DOM tree.