/

HTML / CSS / JavaScript Tutorial

JavaScript title object property: text

[this page | pdf | back links]

The text property of the JavaScript DOM object corresponding to the HTML <title> element sets / returns the text of 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;
document.getElementById("element").innerHTML = 'which is "' + s + '"';
</script>

</body>
</html>


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


Desktop view | Switch to Mobile