Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery代码在IE7中不起作用_Javascript_Jquery_Internet Explorer_Internet Explorer 7 - Fatal编程技术网

Javascript jQuery代码在IE7中不起作用

Javascript jQuery代码在IE7中不起作用,javascript,jquery,internet-explorer,internet-explorer-7,Javascript,Jquery,Internet Explorer,Internet Explorer 7,我使用jQuery1.11.1并执行以下代码: var links= $("#custom-menu").find("li").find("a"); links.each(function(){ if($(this).attr("href")==="#openModal") { $(this).on("click&qu

我使用
jQuery1.11.1
并执行以下代码:

  var links= $("#custom-menu").find("li").find("a");
    links.each(function(){
         if($(this).attr("href")==="#openModal")
        {
            $(this).on("click",function(event){
                alert("Click event called on li");
                $("#openModal").css("visibility","visible").fadeIn();
                alert("Is the table showing now");
            });
        }   
    });
这在IE8中起作用,但在IE7中不起作用,当我单击
li
时不会发生任何事情

编辑: 我已经缩小了范围,控件不进入此块:

 if($(this).attr("href")==="#openModal")

我发现IE7上的internal/in page href属性如下所示:

http://localhost:8080/MyProject/mypage#openModal
而不是
#openModal

所以,与其用这个

 if($(this).attr("href")==="#openModal")
我用过:

 if($(this).attr("href")==="#openModal" || $(this).attr("href") ===(window.location.href+"#openModal"))

在代码中,你在
a
上有一个点击事件,而不是在
li
上。你有一个在线版本,我们可以在那里查看结果吗?@panther它就像一个菜单,最初他们使用
css transitions
来显示它,但不适用于
IE7
,所以,我必须将其更改为使用
visibility
fadeIn/fadeOut
请尝试
this.hash=='#openModal'
在您的if条件下,它也应该在IE7中工作,因为
href
的部分,如
hash
主机
端口
。。。是DOM API中标记的属性