| Viewed 110 times

How to access HTML element in JavaScript


how to access HTML element in JavaScript by id and class name

1 Answer
Mohammad Qandeel
Answered
15

in JavaScript we are using document.getElementById(id) method to access to an HTML element.

as you know  id attribute used to select the HTML element. 

Example

<!DOCTYPE html>
<html>
<body>

<p id="change_me"></p>

<script>
document.getElementById("change_me").innerHTML = "QandeelAcademy";
</script>

</body>
</html>


Related Questions