Title text Property - Change the text of the document's title: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Title

Description

Title text Property - Change the text of the document's title:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Objects</title>
</head>/*from www  . ja  v a2  s . c o m*/
<body>

<p>Click the button to change the text of the document's title.</p>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementsByTagName("TITLE")[0].text = "A new title text..";
    document.getElementById("demo").innerHTML = "changed";
}
</script>

</body>
</html>

Related Tutorials