How to display the title of a document with JavaScript?

HTMLJavascriptProgramming Scripts

To get the title of a document, use the title property in JavaScript. You can try to run the following code to show the title of a document with JavaScript.

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <title>JavaScript Example</title>
   </head>
   <body>
      <script>
         var str = document.title;
         document.write("Title: "+str);
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 08:15:55
Advertisements