Created
November 16, 2012 08:25
-
-
Save tomraithel/4085444 to your computer and use it in GitHub Desktop.
JS: IE7 multiple class fix
This file contains 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
(function($) { // jQuery no conflict container | |
"use strict"; // strict mode on! | |
new function() { // class container | |
// map this to that (to use this in anonymous functions) | |
var that = this; | |
// fires initial Event... | |
$(document).ready(function() { | |
that.fixIE7Classes(); | |
}); | |
/** | |
* Fixes IE7 + < multiple classes bug... | |
* @return {null} | |
*/ | |
this.fixIE7Classes = function() { | |
if ($.browser.msie && $.browser.version < 8) | |
{ | |
$("*").each(function() | |
{ | |
var $obj = $(this); | |
var classes = $obj.attr("class"); | |
if (typeof(classes) == "string" && classes != "") | |
{ | |
var classList = classes.split(" ") | |
if (classList.length > 1) | |
{ | |
$obj.attr("class", ""); | |
$.each(classList, function(k, v) { | |
$obj.addClass(v); | |
}) | |
} | |
} | |
}); | |
} | |
} | |
} // class container closed | |
})(jQuery); // jQuery no conflict container closed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment