How to use id attribute to specify a unique id for HTML element in JavaScript

1 Answer

0 votes
<html>
<head>
<script>
function changeH1() {
  document.getElementById("h1_id").innerHTML = "JavaScript";
}
</script>
</head>
<body>
 
<h1 id="h1_id">HTML CSS</h1>

<button onclick="changeH1()">Click</button>
 
</body>
</html>

 



answered Dec 24, 2018 by avibootz
...