简体   繁体   English

jQuery无法在Internet Explorer中像在其他浏览器中一样工作

[英]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.

相关问题 简单展开(JQuery)在Internet Explorer 11中不起作用,但在其他浏览器中起作用 - Simple-Expand (JQuery) not working in Internet Explorer 11 but works in other browsers Internet Explorer中的Bootstrap Accordion与其他浏览器功能不同 - Bootstrap Accordion in Internet Explorer does not function the same as other browsers jQuery在Internet Explorer中不起作用 - jQuery not working in Internet Explorer setImmediate和Internet Explorer以外的浏览器 - setImmediate and browsers other than Internet Explorer 为什么字符在 Internet Explorer 中“未定义”,而在其他浏览器中却没有 - Why characters are 'undefined' in internet explorer but not in other browsers 在 iframe 中包含 jQuery 时 Internet Explorer 9(不是早期版本或其他浏览器)中的错误 - Error in Internet Explorer 9 (not earlier versions or other browsers) when including jQuery in an iframe 为什么我不能在Internet Explorer中向window.external对象添加方法,但可以在其他浏览器上使用 - why can't I add a method to window.external object in Internet Explorer but working on other browsers 为什么Internet Explorer和Edge与其他浏览器将新的Date()数据输出到数据库不同? - Why does Internet Explorer and Edge output new Date() data into database differently than other browsers? jQuery $ .post()在Internet Explorer中不起作用 - jQuery $.post() not working in Internet Explorer jQuery slideToggle在Internet Explorer 8中不起作用 - jQuery slideToggle not working in Internet Explorer 8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM