71. JavaScript - HTML DOM Methods
What is the most common way to access an HTML element?
The most common way to access an HTML element is to use the id of the element.
What is the programming interface
The programming interface is the properties and methods of each object.
When is innerHTML property useful?
The innerHTML property is useful for getting or replacing the content of HTML elements.
What is a method?
A method is an action you can do (like add or deleting an HTML element).
What is a property
A property is a value that you can get or set (like changing the content of an HTML element).
What are HTML DOM methods for?
HTML DOM methods are actions you can perform (on HTML Elements)
What are HTML DOM properties for?
HTML DOM properties are values (of HTML Elements) that you can set or change
What are elements in the HTML DOM defined?
In the DOM, all HTML elements are defined as objects.
example of a method and property The following example changes the content (the innerHTML) of the <p> element with id="demo":
In the example above, getElementById is a method, while innerHTML is a property. <html> <body> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = "Hello World!"; </script> </body> </html>
The DOM Programming Interface
The DOM Programming Interface
With which programming language can we access the HTML DOM?
The HTML DOM can be accessed with JavaScript (and with other programming languages).
What is the easiest way to get the content of an element?
The easiest way to get the content of an element is by using the innerHTML property.
The getElementById Method
The getElementById Method
The innerHTML Property
The innerHTML Property
Which html element's content can we change with innerHTML?
The innerHTML property can be used to get or change any HTML element, including <html> and <body>.