<html>
<head>
<title>My title</title>
</head>
<body>
<p>Click the button to display the title of the document.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.title;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>