How to work with document.head in JavaScript?

HTMLJavascriptProgramming Scripts

Use the document.head property in JavaScript to get the id of the <head> tag of the document. You can try to run the following code to implement document.head property in JavaScript −

Live Demo

<!DOCTYPE html>
<html>
   <head id = "myid">
      <title>JavaScript Example</title>
   </head>
   <body>
      <h1>Employee Information</h1>
      <form>
         Name: <input type = "text" name = "name" value = "Amit"><br>
         Subject: <input type = "text" name = "sub" value = "Java">
      </form>
      <script>
         var a = document.head.id;
         document.write("<br>Head element id? "+a);
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 14:48:34
Advertisements