Last active
October 27, 2015 11:33
-
-
Save eimfach/27731dd63f750de5cbf1 to your computer and use it in GitHub Desktop.
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
//filter textnodes wrap then in p and remove all br elements | |
$($element.contents()).filter(function(){ | |
this.textContent = _.trim(this.textContent); // trim trailling and leading white spaces | |
return this.nodeType === 3; // filter textnodes only | |
}).wrap('<p></p>').end().filter('br').remove(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment