我想在浏览器低于IE9的情况下执行jQuery中的某些代码。是的,我已经知道了
<!--[if ... IE ]> <![endif]-->
但我想要的是检查脚本标签内的这个条件并使用 jQuery document.ready
<script>
$(document).ready(function(){
//code to check if lt ie9
});
</script>
您可以通过以下类别定位较旧的 Internet Explorer 版本 (<html>元素...
<!--[if lt IE 7]> <html class="ie ie6 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 7]> <html class="ie ie7 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 8]> <html class="ie ie8 lte9 lte8"> <![endif]-->
<!--[if IE 9]> <html class="ie ie9 lte9"> <![endif]-->
<!--[if gt IE 9]> <html> <![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->
...然后检查是否<html>
有课.lt9
or .lt8
— 无论您针对的是哪个版本的 Internet Explorer:
if($('html').hasClass('lte9')) { /* LTE IE9 */ }
但是,我建议使用现代化 http://modernizr.com/功能检测而不是检查特定浏览器。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)