Created
September 13, 2014 06:58
-
-
Save mukunda-/ffa824bbba5d7f572a77 to your computer and use it in GitHub Desktop.
Read element text with converted line breaks
This file contains hidden or 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
// read element text with converted line breaks | |
function readText( element ) { | |
// invisible "workspace" element | |
mb = $('#magicbox'); | |
// copy over the html, with replaced <br> tags | |
var content = $(element).html(); | |
content = content.replace( /<br>/g, '[[br]]' ); | |
mb.html( content ); | |
// return the element text, letting whatever convert | |
// the rest of the html data to text | |
return mb.text().trim(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment