【发布时间】:2010-09-27 16:17:53
【问题描述】:
我在页面中有一张图片,在该图片的onmouseover 事件中,我将调用一个JavaScript 函数来显示工具提示,在图片的onmouseout 中,我将调用一个方法来隐藏工具提示。现在我发现当我将光标放在图像上时,它正在调用显示工具提示div的方法。
如果我在图像中移动鼠标,它会调用onmouseout 事件(即使我不在图像之外)。我怎样才能阻止这个?我希望在光标不在图像时调用onmouseout。有什么想法吗?
我是这样称呼它的:
<img src="images/customer.png" onmouseout="HideCustomerInfo()" onmouseover="ShowCustomerInfo(485)" />
在我的 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
}
【问题讨论】:
标签: javascript dom-events onmouseout