[英]jQuery not working in Internet Explorer as it does in other browsers
I'm building a personal web page, and have put a temporary version on www.aegaeon.comule.com. 我正在建立一个个人网页,并在www.aegaeon.comule.com上放置了一个临时版本。 I followed the Dragon Interactive tutorial (http://labs.dragoninteractive.com/pufferfish_article.php) to make a fading hover menu with a gradient background.
我按照《 Dragon Interactive》教程(http://labs.dragoninteractive.com/pufferfish_article.php)制作了带有渐变背景的褪色悬停菜单。 I've arranged the sub-pages as "panels" to hide and show upon clicking the corresponding navigation button.
我将子页面安排为“面板”,以在单击相应的导航按钮时隐藏和显示。 Here is my javascript/jQuery code:
这是我的javascript / jQuery代码:
var color_text = '#999';
var color_text_hover = "#C0C0C0";
$(function(){
$("div.panel:not(:first)").hide(); // hide all panels except the home panel
var loc=window.location;
window.location.replace(loc+"#home"); // make window location correspond to home panel
var menu=$("#navbar a");
menu.click(function(){
var previous=window.location.hash;
var selected=$(this).attr("href");
if (previous != selected) {
$("div.panel"+previous).fadeOut("slow")
$("div.panel"+selected).fadeIn("slow");
}
menu.removeClass("selected");
$(this).addClass("selected");
});
$('#navbar li a').append('<span class="hover"></span>')
$('#navbar li a').hover(function() {
if(!$(this).hasClass('selected')){
// Stuff that happens when you hover on
$('.hover', this).stop().animate({
'opacity': 0.2
}, 400)
$(this).stop().animate({
//backgroundColor: color_bg_hover,
color: color_text_hover
},400);
}
},function() {
// Stuff that happens when you unhover
$('.hover', this).stop().animate({
'opacity': 0
}, 700, 'easeOutSine')
$(this).stop().animate({
//backgroundColor: color_bg,
color:color_text
},700);
})
});
In Chrome, Firefox, and Safari, the site seems to work fine, but in Internet Explorer it is not. 在Chrome,Firefox和Safari中,该站点似乎可以正常运行,但在Internet Explorer中则不能。 The navigation buttons are initially white, but do become visible when you hover over them, suggesting that the javascript is at least partially working, but I can't explain the different behavior.
导航按钮最初是白色的,但是当您将鼠标悬停在导航按钮上时,它们确实变得可见,这表明javascript至少可以部分工作,但是我无法解释不同的行为。 Any thoughts would be greatly appreciated.
任何想法将不胜感激。
.stop() doesn't work in ie. .stop()在ie中不起作用。
instead of .stop().animate({}); 而不是.stop()。animate({}); use .animate({new animation that you want to apply to the element.});
使用.animate({您要应用于该元素的新动画。});
I see a lot of missing semicolons, for example: 我看到很多缺少的分号,例如:
$("div.panel"+previous).fadeOut("slow")
$("div.panel"+selected).fadeIn("slow");
Check your code. 检查您的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.