Javascript 悬停时移除div
我有这个HTML结构:Javascript 悬停时移除div,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有这个HTML结构: <div class="shadow"></div> <div id="slide_img"> <ul class="clearfix"> <li><img src="themes/company/img/01.png"></li> <li><img src="themes/company/img/02.png"></li> &
<div class="shadow"></div>
<div id="slide_img">
<ul class="clearfix">
<li><img src="themes/company/img/01.png"></li>
<li><img src="themes/company/img/02.png"></li>
<li><img src="themes/company/img/03.png"></li>
<li><img src="themes/company/img/04.png"></li>
<li><img src="themes/company/img/05.png"></li>
<li><img src="themes/company/img/01.png"></li>
</ul>
</div>
如何通过jQuery实现这一点?将您的
.shadow
div放入\slide\u img
中,您可以使用纯CSS实现:
$("#slide_img img").on('mouseenter mouseleave', function() {
$('.shadow').toggle(e.type=='mouseenter');
});
幻灯片:悬停。阴影{
显示:无;
}
如果要临时隐藏此用途
$(document).ready(function(){
$('#slide_img img').hover(
function(){
// When hover the #slide_img img hide the div.shadow
$('div.shadow').hide();
},function(){
// When out of hover the #slide_img img show the div.shadow
$('div.shadow').show();
}
);
});
$('#slide_img img').hover(function(){$('div.shadow').remove();});
特快
否则,您希望完全删除此用途
$(document).ready(function(){
$('#slide_img img').hover(
function(){
// When hover the #slide_img img hide the div.shadow
$('div.shadow').hide();
},function(){
// When out of hover the #slide_img img show the div.shadow
$('div.shadow').show();
}
);
});
$('#slide_img img').hover(function(){$('div.shadow').remove();});
$(“#slide_img img”)。on不是Firebug提供的函数。这意味着您的jQuery版本太旧了,您需要on()的1.7+版本,现在您可能应该使用1.8.2。谢谢。我想问你一个问题。我的阴影div在所有幻灯片img上,当悬停在1 img上时,移除图像上的所有阴影。我想给幻灯片上的阴影分割,但不稳定的宽度我的图像。我不明白你想做什么。是否要使div.shadow仅在其中一个屏幕上悬停并隐藏其他屏幕?