Javascript examples for DOM HTML Element:Title
You can create a <title> element by using the document.createElement() method:
<!DOCTYPE html> <html> <head> </head>/*from www . j a v a2 s .c o m*/ <body> <button onclick="myFunction()">create a TITLE element</button> <p id="demo"></p> <script> function myFunction() { var x = document.createElement("TITLE"); var t = document.createTextNode("HTML DOM objects"); x.appendChild(t); document.head.appendChild(x); document.getElementById("demo").innerHTML = "now created a TITLE element in the HEAD section of your document."; } </script> </body> </html>
Property | Description |
---|---|
text | Sets or gets the text of the document's title |