Get Header Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Header


The Header object represents an HTML <header> element.

You can access a <header> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

  <header id="myHeader">
  <p>This is a test. This is a test. This is a test.</p>
</article>//from  w ww. j a v a  2s.c  o m

<button onclick="myFunction()">set the color of the header element to red</button>

function myFunction() {
    var x = document.getElementById("myHeader"); = "red";


Related Tutorials