Introduction to DOM
1. HTML DOM: When a Web page is loaded, the browser creates a Document object model for the page
2. Dom Operation HTML
JS can change all the HTML elements in the page
JS can change all the HTML properties in the page
JS can change all CSS styles in the page
JS can respond to all the events on the page
Dom manipulating HTML
1. Change the HTML output stream: Note never use document.write () after the document is loaded. This overwrites the document
2. Searching for elements: Finding HTML elements by ID
Find HTML elements with tag names
document.getElementsByTagName ("P");//The first of the same elements
3. Change HTML content: Use attribute: InnerHTML
4. Changing HTML properties: Using attributes: Attribute
Dom manipulating CSS
1. Changing CSS through DOM objects
Syntax: document.getElementById (ID). style.property=new style
DOM EventListener
1. DOM EventListener
Methods: AddEventListener (); method is used to add a time handle to the specified element (more convenient)
Removeeventlistenner (); To remove an event handle added by a method
JavaScript DOM Object