Skip to content

Instantly share code, notes, and snippets.

@yukulele
Created January 17, 2014 14:16
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 yukulele/8473973 to your computer and use it in GitHub Desktop.
Save yukulele/8473973 to your computer and use it in GitHub Desktop.
jQuery Inline CSS remover
jQuery.fn.removeInlineCss = function(property){
if(property == null)
return this.removeAttr('style');
var proporties = property.split(/\s+/);
return this.each(function(){
var remover =
this.style.removeProperty // modern browsers
|| this.style.removeAttribute ; // old browsers (ie 6-8)
for(var i = 0 ; i < proporties.length ; i++)
remover.call(this.style,proporties[i]);
});
};
// remove all inline styles
$(".foo").removeInlineCss();
// remove one property
$(".foo").removeInlineCss("display");
// remove several property
$(".foo").removeInlineCss("color font-size font-weight");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment