/

HTML / CSS / JavaScript Tutorial

JavaScript DOM own property: title

[this page | pdf | back links]

The title property of the JavaScript DOM sets / returns the document <title>.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<title>Title Element</title>
</head>
<body>
Created using HTML:<br>
<span>webpage has title created by HTML</span>

<br><br>Created using JavaScript:<br>
<span id="element"></span>

<script>
var x = document.getElementsByTagName("TITLE")[0]
var s = x.text;
var s2 = document.title
document.getElementById("element").innerHTML = 'which is "' + s + '"'
  + '<br>or (using a different way of accessing the title) "' + s2 +'"';
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile