Last active
August 29, 2015 14:00
-
-
Save xxl007/11124371 to your computer and use it in GitHub Desktop.
Processing Individual Lines of a Textarea
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
// get textarea string and split on new lines | |
var txtBox = document.getElementById("inputbox"); | |
var lines = txtBox.value.split("\n"); | |
// generate HTML version of text | |
var resultString = "<p>"; | |
for (var i = 0; i < lines.length ; i++) { | |
resultString += lines[i] + "<br />"; | |
} | |
resultString += "</p>"; | |
// print out last line to page | |
var blk = document.getElementById("result"); | |
blk.innerHTML = resultString; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment