WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JavaScript - HTML DOM Methods


HTML DOM techniques are actions you can perform (on HTML Elements).

HTML DOM properties are values (of HTML Elements) that you can set or change.


The DOM Programming Interface

The HTML DOM can be gotten to with JavaScript (furthermore, with other programming dialects).

In the DOM, all HTML components are characterized as objects.

The programming interface is the properties and techniques for each object.

A property is an esteem that you can get or set (like changing the substance of a HTML element).

A method is an activity you can do (like include or then again erasing a HTML element).


Example

The following model changes the substance (the innerHTML) of the <p> component with id="demo":

Example

<html>
<body>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = "Hello World!";
</script>

</body>
</html>
Try it Yourself »

In the precedent above, getElementById is a method, while innerHTML is a property.


The getElementById Method

The most normal approach to get to a HTML component is to utilize the id of the element.

In the precedent over the getElementById strategy utilized id="demo" to discover the element.


The innerHTML Property

The most effortless approach to get the substance of a component is by utilizing the innerHTML property.

The innerHTML property is helpful for getting or supplanting the substance of HTML elements.