ccurtin
7/12/2015 - 10:57 PM

Javascript:jQuery: Remove Inline Styles

Javascript:jQuery: Remove Inline Styles

/// REMOVE STYLES plugin
// http://stackoverflow.com/questions/2465158/is-it-possible-to-remove-inline-styles-with-jquery
// USE: $('#element').removeStyle('display');
(function($) {
  $.fn.removeStyle = function(style) {
    var search = new RegExp(style + '[^;]+;?', 'g');

    return this.each(function() {
      if ($(this).attr("style")) {

        $(this).attr('style', function(i, style) {
          return style.replace(search, '');
        });

      }
    });
  };
}(jQuery));