Skip to content

Instantly share code, notes, and snippets.

@dorthrithil
Created July 16, 2015 11:48
Show Gist options
  • Save dorthrithil/a4fff5d1d8b8bfe8e571 to your computer and use it in GitHub Desktop.
Save dorthrithil/a4fff5d1d8b8bfe8e571 to your computer and use it in GitHub Desktop.
A simple function which removes all styles from text pasted from Word or Browsers.
// created for use in textAngulars ta-paste="modifyHtml($html)" option
// http://textangular.com/
$scope.modifyHtml = function($html){
var DOMTree = jQuery(jQuery.parseHTML($html, null, false));
jQuery.each(DOMTree, function(key, value){
jQuery(value).removeAttr('style').find('*').removeAttr('style').removeClass();
});
return jQuery('<div>').append(DOMTree).html();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment