使用jQuery识别IE9 / IE10

我有一个jQuery代码,适用于Chrome / Mozilla但不适用于IE.
if ($("html").hasClass("ie")) {
    $(function(){
        $('.green-column,.red-column,.grey-column').click(function() { 
             alert ($(this).attr("data-type"));           
        });
    });
}
else {
 $(function(){
        $('.green-column,.grey-column').click(function() { 
         $("<div title='Selected Task is:'>" + $(this).attr("data-type") + "</div>").dialog({ 
             modal: true,resizable: false,buttons: [
                {
                   text: "OK",click: function() { $( this ).dialog( "close" ); }
                }
             ]
         });
    });
});
}
</script> 
<!--[if IE 7]>    <html lang="en-us" class="ie"> <![endif]-->
<!--[if IE 8]>    <html lang="en-us" class="ie"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en-us" class="ie"> <!--<![endif]-->

所以我计划使用IE9 / IE10的警报,但我无法区分浏览器.谁能告诉我如何在jQuery / HTML中识别IE9 / IE10?

解决方法

可以在不使用库或条件编译的情况下实现:
if (document.addEventListener) {
    alert("IE9 or greater");
}

if (window.requestAnimationFrame) {
    alert("IE10 or greater");
}

相关文章

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