Created
April 8, 2015 21:13
-
-
Save gyrus/172f19b1ac416a25128c to your computer and use it in GitHub Desktop.
jQuery HTML classes for IE 10+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * A hack to add classes to the HTML element (a la Paul Irish) for IE 10+ | |
| * IE 10 and over no longer support conditional classes. However, sometimes | |
| * you still need to target IE above 9! | |
| */ | |
| jQuery( document ).ready( function( $ ) { | |
| var html = $( html ); | |
| if ( /MSIE 1[01]\.\d+;/.test( navigator.userAgent ) || /Trident/.test( navigator.userAgent ) ) { | |
| html.addClass( 'ie' ); | |
| if ( /MSIE 10\.\d+;/.test( navigator.userAgent ) ) { | |
| html.addClass( 'ie10' ); | |
| html.addClass( 'lt-ie11' ); | |
| html.addClass( 'lt-ie12' ); | |
| } | |
| if ( /MSIE 11\.\d+;/.test( navigator.userAgent ) ) { | |
| html.addClass( 'ie11' ); | |
| html.addClass( 'lt-ie12' ); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment