我有一個圖像表。每一行當被淹沒時,都會顯示它的圖像,該圖像位於已絕對定位的以前隱藏的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