jquery addClass() to first position of multiple classes
(function($) {
jQuery.fn.extend({
prependClass: function(newClasses) {
return this.each(function() {
var currentClasses = $(this).prop("class");
$(this).removeClass(currentClasses).addClass(newClasses + " " + currentClasses);
});
}
});
})(jQuery);
function prependClass(sel, strClass) {
var $el = jQuery(sel);
/* prepend class */
var classes = $el.attr('class');
classes = strClass +' ' +classes;
$el.attr('class', classes);
}