This article mainly introduces some common attribute summary for DOM operations, which is quite comprehensive. the attached example is a very good article about how to improve DOM operations and I recommend it to you.
1. DOM:The Document Object Model DOM (DOM) defines the standard methods for accessing and processing HTML documents. DOM presents HTML documents as a tree (node tree) with elements, attributes, and text ).
2. some common attributes of DOM
2.1 obtain elements by ID
(1) syntax:
The code is as follows:
Document. getElementById ("id ");
(2) function: id refers to a person's id card. we can search for the tag id and perform corresponding operations.
(3) Note: Do not forget to write the document!
2.2 innerHTML attributes
(1) syntax:
The code is as follows:
Obgect. innerHTML = "Hello World"
(2) function: Obtains or replaces the content in the tag.
(3) example:
The code is as follows:
InnerHTML
Javascript
JavaScript is a simple scripting language based on objects and events. it is embedded in HTML documents and is interpreted and executed by the browser, create dynamic display effects on the web page and implement interaction with users.