Javascript examples for DOM HTML Element:Heading
The Heading object represents an HTML heading element: <h1> to <h6>.
You can access a heading element by using getElementById():
<!DOCTYPE html> <html> <body> <h2 id="myHeading">This is a h2 element.</h2> <button onclick="myFunction()">set the color of the h2 element to red</button> <script> function myFunction() {/*from w w w . ja v a 2 s . c o m*/ var x = document.getElementById("myHeading"); x.style.color = "red"; } </script> </body> </html>