The title
property sets or gets the element's advisory title.
HTMLElementObject.title=title
title |
Yes | Yes | Yes | Yes | Yes |
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: