Get Nav Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Nav

Introduction

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>
<html>
<body>

<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>

<script>
function myFunction() {
    var x = document.getElementById("myNav").innerHTML;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials