I am trying to creating simple tooltip on table cells using jQuery.
I wrote this code :
<script type="text/javascript">
$(function () {
$(".test").bind("mouseenter", function (e) {
$("#ToolTipDIv").offset({ left: e.pageX, top: e.pageY });
$("#ToolTipDIv").show("slow");
});
$(".test").bind("mouseleave", function (e) {
$("#ToolTipDIv").hide("slow");
});
});
</script>
<div id="ToolTipDIv" style="background-color: Yellow; display: none; width: 20%;">
This is a text
</div>
<table class="style1" border="1">
<tr>
<td class="test">
1
</td>
<td class="test">
6
</td>
</tr>
<tr>
<td class="test">
2
</td>
<td class="test">
7
</td>
</tr>
</table>
But it does not work as expected. when I bring mouse over cells Tooltip Div closed and opened several times.
for example I want to view tooltip for third Cell I bring mouse pointer over First and second cell to reach the third cell.jQuery tooltip will be show and hide 3 times.
jsfiddle link