Created
April 8, 2015 21:41
-
-
Save dougwollison/6c8daf413b2b65257582 to your computer and use it in GitHub Desktop.
jQuery plugin to remove inline css
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
jQuery.fn.removeStyle = function( property ) { | |
// Remove all styles if no property is specified | |
if ( property === null ) { | |
return this.removeAttr( 'style' ); | |
} | |
// Split the property list | |
var proporties = property.split( /\s+/ ); | |
// Loop through each property and remove them | |
return this.each(function() { | |
// Determine which method to use based on browser | |
var remover = | |
this.style.removeProperty // modern browser | |
|| this.style.removeAttribute; // old browser (ie 6-8) | |
for ( var i = 0 ; i < proporties.length ; i++ ) { | |
remover.call( this.style, proporties[ i ] ); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment