Last active
September 10, 2015 13:38
-
-
Save chrisseldo/f5caa2c9288179ad99e7 to your computer and use it in GitHub Desktop.
A live preview text editor
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
<!-- Basic comment/answer box setup --> | |
<textarea name="Answer" id="Answer" placeholder="Answer"></textarea> | |
<div id="livePre"></div> |
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
// 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