Element title Property - Javascript DOM

Javascript examples for DOM:Element title

Description

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

Return Value

A String, representing the title of the element

The following code shows how to get the title of an <abbr> element:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials