Skip to content

Instantly share code, notes, and snippets.

@chrisseldo
Last active September 10, 2015 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisseldo/f5caa2c9288179ad99e7 to your computer and use it in GitHub Desktop.
Save chrisseldo/f5caa2c9288179ad99e7 to your computer and use it in GitHub Desktop.
A live preview text editor
<!-- Basic comment/answer box setup -->
<textarea name="Answer" id="Answer" placeholder="Answer"></textarea>
<div id="livePre"></div>
// setting the variable 'liveView' to the html div id: Answer
var liveView = document.getElementById('Answer');
// on Answer's keyup I retrieve the inner HTML and set it to the div 'liveView'
liveView.onkeyup = function () {
document.getElementById('livePre').innerHTML = this.value;
}
// Demo: https://jsfiddle.net/chrisseldo/qky7xf0j/3/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment