Tooltip in javascript

Here we take an example in which we specify the ToolTip in javasctipt. When we put our mouse over on the paragraph the tooltip will be show. (Here we take a paragraph as a tooltip.

<html>
<head>
<script type="text/javascript">
function getmytooltip(x)
{
document.getElementById('mytooltip').innerHTML=x;
}

function reset()
{
document.getElementById('mytooltip').innerHTML="";
}
</script>
</head>

<body>

<p onmouseover="getmytooltip('My name is mahak garg')"
onmouseout="reset()">Mahak</p>
<p id="mytooltip"></p>
</body>
</html>

Here mytooltip is the second paragraph which is used as tooltip.


Output:

1.png


Ebook Download
View all
Learn
View all