2014-02-23 22 views
0

http://jsfiddle.net/Y5MRL/ 我使用jquery在用户点击透明div时弹出一个图像。图像应该是超链接到一个url。但图像弹出后没有超链接。问题是什么?Jquery代码禁用图像上的超链接?

HTML

<a href="https://www.google.com/"><img id="enterout4" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSRDwuNVz5koLf3uGVSWt_otiZsKwCVAQK8gb0ppY3GFULHEU0C2w"></a> 

jQuery的

$('#enter4').mouseenter(function(){ 
    $('#enterout4').fadeIn('slow'); 
    $('#enterout4').width($(window).width()/4.6); 
    console.log(); 
}); 

$('#enter4').mouseleave(function(){ 

    $('#enterout4').fadeOut('slow'); 
}); 

CSS:

#enter4{ 
    position: absolute; 
    z-index: 9999; 
    width: 300px; 
    height: 100px; 
    top: 0%; 
    left: 0%; 
    opacity: 0; 
} 

#enterout4{ 
    position: absolute; 
    top: 0%; 
    left: 0%; 
    z-index: 9998; 
    display: none; 
    height:auto; 
} 

这里是例子 http://jsfiddle.net/Y5MRL/

+0

哪里是'#enter4',以及为什么使用'jQuery的1.9.1','迁移1.1.0' 'jQuery UI的1.9.2','jQuery Mobile的1.3.0b1'和'jQuery Mobile的1.2。 0'在同一时间? :) – davidkonrad

回答

0

你举的例子是我不完整的,但我想你徘徊为什么在淡出效果后,你不能再点击任何东西。这是因为fadeOut()方法也会将显示设置为无。

您应该比使用animate()方法进行淡入淡出设置不透明度为零,反之亦然。

我添加了调试背景颜色到div看到可点击区域。

$('#enterout4') 
.css({ opacity: 0 }) 
.hide(); 
$('#enter4').mouseenter(function(){ 
    $('#enterout4').show(); 
    $('#enterout4') 
    .animate({opacity: 1, width: $(window).width()/4.6,}, 1500); 
}); 

$('#enter4').mouseleave(function(){ 
    $('#enterout4').animate({ opacity: 0, duration: 1500 }); 
}); 

查看改进的js小提琴使用动画宽度和不透明度。 编辑:我想我现在明白了。你有一个ID为enter4的div。 http://jsfiddle.net/P5j5m/22/