实例
例子 1
返回 body 元素的 title 属性:
var x=document.getElementsByTagName('body')[0];
document.write("Body title: " + x.title);
document.write("
");
document.write("替代方法:");
document.write(document.getElementById('myid').title);
输出:
Body title: mytitle
替代方法:mytitle
例子 2
返回图像映射中某个区域的咨询标题:
width="145" height="126"
alt="Planets"
usemap ="#planetmap">
coords ="124,58,8"
title="Venus"
href ="venus.htm">
Venus' advisory title (mouse over the Venus planet):
var x=document.getElementById('venus')
document.write(x.title)