JSFiddle - React, Tailwind, and code Playground

Run Script From Textarea

by skibulk

HTML

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<form>
	<textarea id="beforeRun"></textarea>
	<button id="run" type="button">Run</button>
	<pre id="console"></pre>
</form>

CSS

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

#beforeRun, #console {
	width: 100%;
	height: 100px;
}
#run {
	width: 100px;
	height: 20px;
}
#console {
	background: #EAEAEA;
}

JavaScript

$("#run").click(function(event) {
	eval( $("#beforeRun").val() );
});

console.log2 = console.log;
console.log = function() {
	console.log2.apply(null, arguments);
	$("#console").append( JSON.stringify(arguments) + "\r\n" );
};