我有一个图像表。每一行当被淹没时,都会显示它的图像,该图像位于已绝对定位的以前隐藏的div中。当我将鼠标移到现在显示的图像上时,我想要解除tr mouseleave事件,以便图像不闪烁,然后在离开图像div时重新绑定mouseleave事件。问题绑定鼠标事件
我可以解除mouseleave事件,但重新绑定会导致闪烁发生。相关代码:
<table border="1" id="photoTable">
<tbody>
<tr class="item">
<td class="filename">
GraphDataCAQ3UW88.png
</td>
</tr>
</tbody>
</table>
<div id="thisPhoto"></div>
CSS:
#thisPhoto{
display:none;
position:absolute;
left:250px;
top:150px;
border: 1px solid black;
background-color:white;
padding:20px;
z-index:2;
}
JS:
$(document).ready(function(){
(function($){
$.fn.getThisPhoto = function(){
return $(this).each(function(){
//I've left out the code which gets the data to pass to $.get()
$.get('administration/PhotoManagement/thisPhoto.cfm',
data,
function(response){
$('#thisPhoto').html(response).show();
}
);
});
};
})(jQuery);
$('tr.item').hover(function(){
$(this).getThisPhoto();
},
function(){
$('#thisPhoto').hide();
});
$('#thisPhoto').mouseenter(function(){
$('tr.item').unbind('mouseleave');
}).mouseleave(function(){
$('tr.item').bind('mouseleave', function(){
$('#thisPhoto').hide();
});
});
});
编辑:我在一个div包裹整个家当和对div来触发设置鼠标移开黑客攻击hide()和bind()函数...不完全是我想要的,但它会在一个捏。
尼斯 - 会试一试。我正在使用dataTables插件,所以我不确定额外的div是否会打破它。 – earachefl