Document title Property - Change the title of the document: - Javascript DOM

Javascript examples for DOM:Document title

Description

Document title Property - Change the title of the document:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<title>My title</title>
</head>// w ww .  ja v  a2 s.c o  m
<body>

<button onclick="myFunction()">change the title of the document</button>

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

<script>
function myFunction() {
    document.title = "Some new title text";
    document.getElementById("demo").innerHTML = "changed from 'My title' to 'some new title text'.";
}
</script>

</body>
</html>

Related Tutorials