Javascript examples for DOM:Document title
The title property sets or gets the title of the current document, which is the text inside the HTML title element.
Set the title property with the following Values
Value | Description |
---|---|
newTitle | Sets a new title text |
A String, representing the title of the document
The following code shows how to get the title of the current document:
<!DOCTYPE html> <html> <head> <title>My title</title> </head>/*from w w w .j ava 2s.c om*/ <body> <button onclick="myFunction()">change the title of the document</button> <p id="demo"></p> <script> function myFunction() { var v = document.title; document.getElementById("demo").innerHTML = v; } </script> </body> </html>