对于某些情况,例如 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?

查看:36
本文介绍了对于某些情况,例如 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="en" class="no-js"> 而不是 <html class="no-js ie10" lang="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天全站免登陆