Javascript examples for DOM HTML Element:Heading
Hovering over a <h1> and changing value of <p>
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w ww . java 2 s . c om var h1 = document.getElementById("myH1"); var myP = document.getElementById("myP"); h1.addEventListener("mouseover", mouseOver); function mouseOver(){ myP.innerHTML = "new value"; } } </script> </head> <body> <h1 id="myH1">this is the h1</h1> <p id="myP">this is the p</p> </body> </html>