Guest User

Untitled

a guest
Apr 26th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. // jQuery's default text() method doesn't play nice with contentEditable
  2. // elements, which insert divs or paras instead of newline characters.
  3. // Convert them properly.
  4. textWithNewlines: function( text ) {
  5. var ret = "";
  6. $.each( text || this, function(){
  7. $.each( this.childNodes, function() {
  8. if ( this.nodeType != 8 ) {
  9. ret += this.nodeType != 1 ? this.nodeValue : $.fn.textWithNewlines([this]);
  10. }
  11. var tagName = this.tagName && this.tagName.toLowerCase();
  12. if (tagName == 'div' || tagName == 'p') ret += "\n";
  13. });
  14. });
  15. return ret;
  16. }
Add Comment
Please, Sign In to add comment