Javascript DOM HTML Element title Property set

Introduction

Change the title of the document:

document.title = "Some new title text";

Click the button to change the title of the document.

View in separate window

<!DOCTYPE html>
<html>
<head>
<title>My title</title>
</head>/* w  ww.  j  av a2 s  .  co  m*/
<body>
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
  document.title = "Some new title text";
  document.getElementById("demo").innerHTML = "The title of the document was changed.";
}
</script>

</body>
</html>



PreviousNext

Related