How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?(对于某些情况,如 Internet Explorer 特定的 CSS 或 Internet Explorer 特定的 JavaScript 代码,如何仅针对 Internet Explorer 10?) - IT屋
问题描述
对于某些情况,如 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?
我试过了,但它不起作用:
I tried this, but it doesn't work:
<!--[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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:对于某些情况,如 Internet Explorer 特定的 CSS 或 Internet Explorer 特定的 JavaScript 代码,如何仅针对 Internet Explorer 10?


- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01