Jquery 下拉菜单仅在 IE 上闪烁
我正在为一个新项目启动一个 Jquery 下拉菜单,它在 Google Chrome、Firefox、Safari 上按预期工作,但当然它在 Internet Explorer 上让我有些头痛。
事情是这样的, 请参阅此页 http://www.universidadedoingles.com.br/dev/index.ASP
将鼠标悬停在菜单“HOME”上时,会出现下拉菜单,当您将鼠标移到 IE 中的链接上时,您会看到一些背景闪烁,这在 Chrome 和 ETC 上不会发生。
这是我用来做 dd 菜单的 js coda。
<script type="text/javascript">
$(document).ready(function() {
$("ul.mainmenu li.menuhome").mouseover(function(){
$(".arrow-spacer").show(); //When mouse over ...
//Following event is applied to the subnav itself (making height of subnav 150px)
$(this).find('.submenu').show().animate({height: '150px', opacity:'1'},{queue:false, duration:300})
});
$("ul.mainmenu li.menuhome").mouseout(function(){ //When mouse out ...
//Following event is applied to the subnav itself (making height of subnav 0px)
$(this).find('.submenu').hide().animate({height:'0px', opacity:'0'},{queue:false, duration:200})
});
//menu itembackground color animation
$("li").hover(function() {
$(this).animate();},
function() {
$(".arrow-spacer").hide();
});
});
</script>
就是这样,我想这可能很简单,但已经过去几周了,我仍然无法让它工作。
多谢。
I am starting a Jquery drop down menu for a new project and it is working as expected on Google Chrome, Firefox, Safari but of course it is giving me some headache on Internet Explorer.
here's the thing,
See this page
http://www.universidadedoingles.com.br/dev/index.ASP
on mouse over the menu HOME, the drop down appers, when you move over the links in IE you see some flashes of the background, which doesn't happens on Chrome and ETC.
here's the js coda I am using to do the dd menu.
<script type="text/javascript">
$(document).ready(function() {
$("ul.mainmenu li.menuhome").mouseover(function(){
$(".arrow-spacer").show(); //When mouse over ...
//Following event is applied to the subnav itself (making height of subnav 150px)
$(this).find('.submenu').show().animate({height: '150px', opacity:'1'},{queue:false, duration:300})
});
$("ul.mainmenu li.menuhome").mouseout(function(){ //When mouse out ...
//Following event is applied to the subnav itself (making height of subnav 0px)
$(this).find('.submenu').hide().animate({height:'0px', opacity:'0'},{queue:false, duration:200})
});
//menu itembackground color animation
$("li").hover(function() {
$(this).animate();},
function() {
$(".arrow-spacer").hide();
});
});
</script>
That's it, I guess it may be simple, but it's been weeks and I still can't get it to work.
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我注意到锚点
标签上有一个边距。我的第一件事是尝试使用填充来代替。 IE 对待边缘悬停的方式与其他浏览器不同。
I noticed that the anchor
<a>
tags have a margin on them. My first thing would be to try using padding instead. IE doesn't treat a hover in the margin the same way as other browsers.在某些情况下,在应放置在其他元素之上的元素上设置
z-index
会有所帮助。在您的情况下,我会尝试在
上设置
z-index
in some cases it helps to set a
z-index
on elements that should placed in top of other elements.In your case I would try to set the
z-index
on<ul class="submenu">
不再眨眼了!我把一个单词hide()改成了stop(),现在iE上就没有闪烁了。但是...
显示菜单1次后,每次将鼠标移到链接下方或关闭链接时,菜单都会再次显示。
检查这个
www.universidadedoingles.com.br/dev
你将能够看到它的行为
No blinks anymore! I changed one word hide() to stop (), now there is no blinking on iE. but...
After you show the menu 1 time, everytime you get your mouse below the link or close the link, the menu shows up again.
check this
www.universidadedoingles.com.br/dev
you'll be able to see its behavior
问题是,当您将鼠标悬停在
元素上时,
的焦点就会丢失。
您可以使用以下方法来克服这个问题。我避免使用
标签,而是使用 JavaScript 函数将用户发送到首选位置。我使用 JavaScript 而不是 jQuery,希望使其更加不言自明。
The thing is that the focus to
<li>
is lost when you mouse over an<a>
element.Here is something you could use to overcome this. I avoided using the
<a>
tag, instead I used a JavaScript function to send the user to the preferred location. I used JavaScript rather than jQuery hoping to make it more self-explanatory.