鉴于下面显示的html表和脚本我有一个问题,即鼠标输入后鼠标离开事件发生,即使我不移动将鼠标移出该行。jquery:mouseleave事件似乎不应该触发
<script type="text/javascript" language="javascript">
function highlightRows(iMainID)
{
$('tr[mainid=' + iMainID+ ']').each(function() {
if ($(this).attr('old') == undefined) {
$(this).attr('old', $(this).css('backgroundColor'));
}
$(this).animate({ backgroundColor: "#FFFFCC" }, 500);
$(this).mouseout(function() {
if ($(this).attr('old') != undefined) {
$(this).animate({ backgroundColor: $(this).attr('old') }, 500);
}
});
});
}
</script>
<table>
<tr>
<td mainid="1" onmouseover='highlightRows(1)'><div>text</div></td>
<td mainid="1" onmouseover='highlightRows(1)'><div>text</div></td>
<td mainid="2" onmouseover='highlightRows(2)'><div>text</div></td>
</tr>
<table>
你真的不应该在“mouseover”处理程序中设置“mouseout”处理程序。事先分别设置这两个处理程序,并使用jQuery而不是“onfoo”元素属性来完成。 – Pointy 2010-03-08 19:01:46
当我有重叠元素时,发生在我身上。计算机在两个元件之间切换,并且这样做非常快速地进入和离开。 – 2014-10-26 02:47:47