HTML DOM title Property
Definition and Usage
The title property sets or returns the element's advisory title.
Syntax
Example 1
The following example shows two methods on how to get the title attribute of the <body>
element:
<html>
<body id="myid" title="mytitle">
<script type="text/javascript">
x=document.getElementsByTagName('body')[0];
document.write("Body title: " + x.title);
document.write("<br />");
document.write("An alternate way: ");
document.write(document.getElementById('myid').title);
</script>
</body>
</html>
|
Output:
Body title: mytitle
An alternate way: mytitle
|
Example 2
The following example returns the advisory title of an area in an image-map:
<html>
<body>
<img src ="planets.gif"
width="145" height="126"
alt="Planets"
usemap ="#planetmap" />
<map name ="planetmap">
<area id="venus" shape="circle"
coords ="124,58,8"
title="Venus"
href ="venus.htm" />
</map>
<p>Venus' advisory title (mouse over the Venus planet):
<script type="text/javascript">
x=document.getElementById('venus')
document.write(x.title)
</script>
</p>
</body>
</html>
|
Try-It-Yourself Demos
Return
the title attribute of the <body> element
Return
the advisory title of an area in an image-map
Learn XML with <oXygen/> XML Editor - Free Trial!
|
|
oXygen helps you learn to define,
edit, validate and transform XML documents. Supported technologies include XML Schema,
DTD, Relax NG, XSLT, XPath, XQuery, CSS.
Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!
Do you have any XML related questions? Get free answers from the oXygen
XML forum
and from the video
demonstrations.
Download a FREE 30-day trial today!
|
|