Skip to content

Instantly share code, notes, and snippets.

@oliverbenns
Last active December 24, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oliverbenns/6740630 to your computer and use it in GitHub Desktop.
Save oliverbenns/6740630 to your computer and use it in GitHub Desktop.
Nth-of-type IE7 & IE8 Fallback [jQuery]
<!--[if lt IE 7]> <html class="ie ie6 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 7]> <html class="ie ie7 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 8]> <html class="ie ie8 lte9 lte8"> <![endif]-->
<!--[if !IE]><!--> <html><!--<![endif]-->
// Adds class 'l-end-col' to matched elements.
function nthFallback(ele, nth) {
if ($('html').hasClass('lte8')) {
$(ele + ':nth-of-type(' + nth + ')').addClass('l-end-col');
}
}
// To run - e.g. select every 4th <li>
nthFallback('ul li','4n+4');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment