atributo de título HTML DOM
Definición y Uso
conjuntos de propiedades de título o devuelve los elementos del título.
gramática
HTMLElementObject.title=title
Soporte para el navegador
Todos los principales navegadores soportan el atributo del título
Ejemplos
Ejemplo 1
Devuelve el atributo de título del elemento del cuerpo:
<html>
<body id="myid" title="mytitle">
<script>
var 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>
<body id="myid" title="mytitle">
<script>
var 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>
salida:
Body title: mytitle
An alternate way: mytitle
An alternate way: mytitle
Trate »
Ejemplo 2
De vuelta en el mapa título área de la imagen:
<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>
var x=document.getElementById('venus')
document.write(x.title)
</script>
</p>
</body>
</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>
var x=document.getElementById('venus')
document.write(x.title)
</script>
</p>
</body>
</html>
Trate »