我有一个图像。
如果鼠标悬停,下一个图像和上一个图像的控件将显示在图像上(通过CSS移动到那里)。如果鼠标悬停控件的图像,则外壳将消失。
问题是,如果鼠标悬停在某个控件上,则鼠标悬停图像,控件消失:-(
我该怎么办?我尝试过类似的方法,但它不起作用:
var控制=假;
$('.detail_img').bind('mouseover', function(){
$('.gal_control').fadeIn(200);
});
$('.detail_img').bind('mouseout', function(){
if(!control) $('.gal_control').fadeOut(400);
});
$('.gal_control').bind('mouseover', function(){
control = true;
});
$('.gal_control').bind('mouseout', function(){
control = false;
});
谢谢你帮我
HTML…对于所有没有幻想的人:—)
<div class="rollover_left gal_control"></div>
<div class="rollover_right gal_control"></div>
<img class="detail_img" id="detail_img" src...>
更新
var control = false;
$('.detail_img').bind('mouseover', function(){
control = true;
$('.gal_control').fadeIn(200);
});
$('.detail_img').bind('mouseout', function(){
control = false;
});
$('body').bind('mouseover', function(){
if(!control) $('.gal_control').fadeOut(400);
});
$('.gal_control').bind('mouseover', function(){
control = true;
});
$('.gal_control').bind('mouseout', function(){
control = false;
});
我的意思是,现在就这样了,但有更好的方法吗?我能优化这些线条吗?