Javascript examples for DOM:Element title
The title property sets or gets the title attribute of an element, which is shown as a tooltip text when the mouse moves over the element.
Set the title property with the following Values
Value | Description |
---|---|
text | A tooltip text for an element |
A String, representing the title of the element
The following code shows how to get the title of an <abbr> element:
<!DOCTYPE html> <html> <body> <p id="myP" title="Free Web tutorials">java2s.com</p> <button onclick="myFunction()">Test</button> <script> function myFunction() {/* w w w .j av a 2 s . c om*/ var v = document.getElementById("myP").title; console.log(v); } </script> </body> </html>