如何在特定情况下(例如特定于Internet Explorer的CSS或Internet Explorer特定的JavaScript代码)仅定位Internet Explorer 10? [英] How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?

查看:134
本文介绍了如何在特定情况下(例如特定于Internet Explorer的CSS或Internet Explorer特定的JavaScript代码)仅定位Internet Explorer 10?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在特定情况(例如特定于Internet Explorer的CSS或特定于Internet Explorer的JavaScript代码)中仅定位Internet Explorer 10?

How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?

工作:

<!--[if IE 10]>    <html class="no-js ie10" lang="en"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->

Internet Explorer 10忽略条件注释,并使用< html lang =enclass =no-js> 而不是< html class =no-js ie10lang =en>

Internet Explorer 10 ignores the conditional comments and uses the <html lang="en" class="no-js"> instead of <html class="no-js ie10" lang="en">.

推荐答案

也许你可以这样尝试一些jQuery:

Perhaps you can try some jQuery like this:

if ($.browser.msie && $.browser.version === 10) {
  $("html").addClass("ie10");
}

要使用此方法,必须包含jQuery Migrate库,从主jQuery库。

To use this method you must include the jQuery Migrate library because this function was removed from the main jQuery library.

对我来说很好。但是肯定不能替换条件注释!

Worked out quite fine for me. But surely no replacement for conditional comments!

这篇关于如何在特定情况下(例如特定于Internet Explorer的CSS或Internet Explorer特定的JavaScript代码)仅定位Internet Explorer 10?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆