Get Nav Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Nav


The Nav object represents an HTML <nav> element.

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<nav id="myNav">
  <a href="#">HTML</a> |
  <a href="#">CSS</a>
</nav>/*from   w  w w . j  ava  2 s.  c o  m*/

<button onclick="myFunction()">get the HTML content of the nav element</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("myNav").innerHTML;
    document.getElementById("demo").innerHTML = x;


Related Tutorials