How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?
conditional-comments, css, html, internet-explorer-10, javascript
Solution
Perhaps you can try some jQuery like this:
if ($.browser.msie && $.browser.version === 10) {
$("html").addClass("ie10");
}
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!
Problem
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 ignores the conditional comments and uses the `<html lang="en" class="no-js">` instead of `<html class="no-js ie10" lang="en">`.
Related problems
- How to write a CSS hack for IE 11?
- Does Firefox support position: relative on table elements?
- What is the !! (not not) operator in JavaScript?
- Webkit bug with `:hover` and multiple adjacent-sibling selectors
- Which equals operator (== vs ===) should be used in JavaScript comparisons?
- Firefox 4 ignoring box-sizing?
- CSS "outline" different behavior behavior on Webkit & Gecko
- Combine CSS Attribute and Pseudo-Element Selectors?