I'm making my own IDE and I need a way of running code(HTML) from a JavaScript function call.
I have a div I need the user to click a button then the div will contain html which is from a textarea.
By RUNNING HTML CODE I mean to get input from a text area and dump it into a div so it it running in the div
(my IDE is by far the best workspace) My Workspace
Here is my CODE:`
<textarea class="txtarea"></textarea>
<div class="browser">A Browser</div>
<button class="run-btn">RUN</button>
<script>
var num = 0;
$(".browser").hide(); // hide my div
$(".run-btn").click(function() {
num++;
if (num % 2 == 1) {
$(".txtarea").hide();
$(".browser").show(); // my div
$(".browser").text($(".txtarea").val());
}
if (num % 2 == 0) {
$(".txtarea").show();
$(".browser").hide();
}
});
</script>