Javascript Reference - HTML DOM title Property








The title property sets or gets the element's advisory title.

Syntax

HTMLElementObject.title=title

Browser Support

title Yes Yes Yes Yes Yes

Example 1

The following code shows how to get the title attribute of the body element.


<!DOCTYPE html>
<html>
<body id="myid" title="mytitle">
<!-- w  w  w.  j a  v  a  2 s.  co m-->
<script>
    var x=document.getElementsByTagName('body')[0];
    document.write("Body title: " + x.title);
    document.write("<br/>");
    document.write(document.getElementById('myid').title);
</script>

</body>
</html>

The code above is rendered as follows: