HTML DOM Nav Object | Nav Tag in HTML | HTML5 Nav

HTML DOM Nav Object


Standard Properties and Events

The Nav object supports the standard properties and events.

Example

We can access a <nav> element by using getElementById().


<!DOCTYPE html>
<html>
<body>
<nav id="myNav"><a href="#">HTML</a> |<a href="#">CSS</a></nav>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!--   w  w w .jav  a 2  s  . c om-->
<script>
function myFunction() {
    var x = document.getElementById("myNav").innerHTML;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

The code above is rendered as follows: