javascript – 如何使用jQuery.support检测IE7和更低版本?

目前我正在使用jQuery.browser来检测IE7和更低版本
if ($.browser.msie && parseInt($.browser.version) <= 7) {
    //codes
}

但是jQuery.browser在jQuery 1.3中被弃用并在jQuery 1.9中被删除,我从jQuery网站上读到我们应该使用特征检测(jQuery.support).

那么,如何使用jQuery.support检测IE7和更低?

解决方法

最好的方法是使用条件注释并使用jQuery的hasClass()进行检查.
<!--[if lt IE 7]>      <html class="ie6"> <![endif]-->
<!--[if IE 7]>         <html class="ie7"> <![endif]-->
<!--[if IE 8]>         <html class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html>         <!--<![endif]-->

在你的jQuery中,检查IE 7:

// Check IE 7
if ($('html').hasClass('ie7');

无论如何,这种方法都不能被欺骗.另见:Conditional Stylesheets by Paul Irish.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...