小编nkt*_*nkt的帖子

使用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, .red-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]-->
Run Code Online (Sandbox Code Playgroud)

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

html jquery internet-explorer browser-detection

4
推荐指数
3
解决办法
3万
查看次数