[Solved] Using JS how can I select a HTML 5 element?


For that you could use querySelector, which takes a CSS selector as a parameter

   var element = document.querySelector("nav");
   element.classList.add("mystyle");

If that nav is a child of e.g. a header, you could add its selector to grab only nav that is within such parent

   var element = document.querySelector("header nav");
   element.classList.add("mystyle");

It is situations like the latter where it really excel’s with its CSS selector parameter

solved Using JS how can I select a HTML 5 element?