title: How to run HTML code from a js function
body: <p>I'm making my own IDE and I need a way of running code(HTML) from a JavaScript function call.</p>
  
  <p>I have a div I need the user to click a button then the div will contain html which is from a textarea.</p>
  
  <p><i>By <b>RUNNING HTML CODE</b> I mean to get input from a text area and dump it into a div so it it running in the div</i></p>
  
  <p>(my IDE is by far the best workspace) <a href="http://i.stack.imgur.com/LIFgX.jpg" rel="nofollow">My Workspace</a></p>
  
  <p>Here is my CODE:`</p>
  
  <pre><code>&lt;textarea class="txtarea"&gt;&lt;/textarea&gt;
  
  &lt;div class="browser"&gt;A Browser&lt;/div&gt;
  
  &lt;button class="run-btn"&gt;RUN&lt;/button&gt;
  
  &lt;script&gt;
  
  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();
    }
  });
  
  
  &lt;/script&gt;
  </code></pre>