我试图在悬停时为图像上色,我也希望删除图标出现在图像上,我面临的问题是当鼠标悬停在删除图标上时,许多事件不断发生。
这是HTML
<span class="imageContent" >
<a class="imgOverlay" href="http://4.bp.blogspot.com/-yAOYE3-J1mo/TmsnBJ6ucYI/AAAAAAAABcA/5ZKqEv3p-6I/s1600/36676-sky_blue.jpg" target="_blank" >
<img src="http://4.bp.blogspot.com/-yAOYE3-J1mo/TmsnBJ6ucYI/AAAAAAAABcA/5ZKqEv3p-6I/s1600/36676-sky_blue.jpg" />
</a>
<a href="" name="deleteImg" class="delete">delete</a>
</span>
这是js
$(".imgOverlay > img").hover(function(e){
$(this).fadeTo("fast",0.3);
$('.delete').css('display','inline-block');
},function(e){
$(this).fadeTo("fast",1.0);
$('.delete').css('display','none');
});
$(".imgOverlay > .delete").hover(function(e){
$('.delete').css('display','inline-block');
},function(e){
$('.delete').css('display','none');
});
$('.imgOverlay .delete').click(function(e){
alert('click');
});
这是一个现场示例 http://jsbin.com/asehuq/1/edit