English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
HTML DOM methods are the operations that can be performed on HTML elementsOperation.
HTML DOM properties are the HTML elements that can be set or changedValue.
HTML DOM can be accessed using JavaScript (and other programming languages).
In the DOM, all HTML elements are defined asobjects.
The programming interface is the properties and methods of each object.
OnePropertyIt is a value that you can get or set (such as changing the content of an HTML element).
OneMethodIs the action you can do (such as adding or deleting HTML elements).
You don't have to do anything special to start using DOM.
This example uses thegetElementById()innerHTML,
<!DOCTYPE html> <html> <p id="para"></p> <script> document.getElementById("para").innerHTML = "Hello world"; </script> </html>Test to see‹/›
In the above example,getElementById()IsMethod,innerHTMLInsteadProperty.
The most common way to access HTML elements is to use the id element.
In the above example,getElementById()The method used to find an element by id="para" is.
The simplest way to get the content of an element is to useinnerHTMLProperty.
innerHTMLProperties are very useful for retrieving or replacing the content of HTML elements.
For a complete reference to properties and methods, please visit ourJavaScript DOM Reference.
The reference section includes descriptions and examples of all DOM properties and methods.