简体   繁体   English

IE8不能与jQuery .show()一起使用,并且不能在所有其他浏览器(包括ie9)上使用

[英]IE8 not working with jQuery .show() and working on all other browsers including ie9

I have the following HTML: 我有以下HTML:

<a class="select_class" style="font-size: 15px;"></a> 
<div class="dropDown" style="display: none;" >
    <!--somecode-->
</div>

And Javascript: 和Javascript:

$('.select_class').click(function(){  
    var isVisible = $('.dropDown').is(':visible'); 

    if (isVisible) { 
        $('.dropDown').hide(); 
    } 
    else { 
        $('.dropDown').show(); 
    } 
    return false; 
});

It is giving me error that "null is null or not an object." 这给我一个错误,即“ null为null或不是对象”。 and its working fine in IE9, Firefox and Chrome. 并且可以在IE9,Firefox和Chrome中正常运行。 Only in IE8 I am getting this issue. 仅在IE8中,我遇到了此问题。

Error is on the following line: 错误在以下行:

var isVisible = $('.dropDown').is(':visible');

Finally it worked..:) I replaced '$' symbol with 'jquery' and it worked :-) something like this: 终于奏效了.. :)我用'jquery'代替了'$'符号,并且奏效了:-)像这样:

jQuery('.select_class').click(function(){  
        var isVisible = jQuery('.dropDown').is(':visible'); 

        if (isVisible) { 
             jQuery('.dropDown').hide(); 
         } 
        else { 
            jQuery('.dropDown').show(); 
        } 
        return false;  });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM