how to detect IE11 using jquery [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-03 02:26:54
swt

Try this:

var isIE11 = !!navigator.userAgent.match(/Trident.*rv\:11\./);
alert(isIE11);

EDIT:

Editted in a regex fix, taken from the comments. This fix works in the current version of IE11 as of 2/17/2014.

That last one was correct.

Example:

To apply a body style for IE only for IE7 and above (including 10+11...)

Copy/Paste this code inside the <head></head> tag:

<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>//<![CDATA[ 
$(function(){
      if(navigator.userAgent.match(/Trident\/7\./)) {
          $('body').addClass('if-ie');
     }


});//]]>
</script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!