Skip to content

Instantly share code, notes, and snippets.

@tomraithel
Created November 16, 2012 08:25
Show Gist options
  • Save tomraithel/4085444 to your computer and use it in GitHub Desktop.
Save tomraithel/4085444 to your computer and use it in GitHub Desktop.
JS: IE7 multiple class fix
(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