I have an image in a page and in the onmouseover
event of that image I will call a JavaScript function to show a tooltip and in the onmouseout
of the image, I will call a method to hide the tooltip. Now I found that when I place the cursor on the image, it's calling the method to show the tooltip div.
And if I move the mouse within the image, it's calling the onmouseout
event (even if I am not out of the image). How can I stop this? I want onmouseout
to be called when the cursor is out of the image. Any thoughts?
Here is how I call it:
<img src="images/customer.png" onmouseout="HideCustomerInfo()" onmouseover="ShowCustomerInfo(485)" />
And in my JavaScript:
function ShowCustomerInfo(id) {
var currentCustomer = $("#hdnCustomerId").val();
if (currentCustomer != id) { // to stop making an ajax call everytime when the mouse move on the same image
$.get('../Lib/handlers/userhandler.aspx?mode=custinfo&cid=' + id, function (data) {
strHtml = data;
});
tooltip.show(strHtml); // method in another jquery pluggin
$("#hdnCustomerId").val(id);
}
}
function HideCustomerInfo() {
tooltip.hide(); // method in another jquery pluggin
$("#hdnCustomerId").val(0); //setting in a hidden variable in the page
}