Javascript examples for DOM HTML Element:Nav
You can create a <nav> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create a NAV element containing a link</button> <p id="myP"></p> <script> function myFunction() {//w w w . ja v a 2 s. c om var x = document.createElement("NAV"); document.body.appendChild(x); var anchorElmnt = document.createElement("A"); anchorElmnt .setAttribute("href", "/html"); var txt1 = document.createTextNode("HTML"); anchorElmnt .appendChild(txt1); x.appendChild(anchorElmnt); } </script> </body> </html>