我有一个 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]-->
所以我打算为 IE9/IE10 使用警报,但我无法区分浏览器。谁能告诉我如何在 jQuery/HTML 中识别 IE9/IE10?
最佳答案
无需使用库或条件编译即可实现:
if (document.addEventListener) {
alert("IE9 or greater");
}
if (window.requestAnimationFrame) {
alert("IE10 or greater");
}
关于jquery - 使用 jQuery 识别 IE9/IE10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15657614/