I'm trying to create an input where someone can write javascript in a text area. After they click a button, I load the script they wrote in the text area and insert it into an html div that will be saved (saving this and other html elements as a custom created page basically)
However, when I insert the javascript into the div with jquery, it just runs the script, but does not insert the content. Is there a way to get the code to both run and copy over into the html so I can save what was written?
Edit: Here's an example:
HTML:
JS: (Jquery) $('#myDiv').html('window.alert("test")');
Pops an alert window up, $('#myDiv').html() = "", div is still empty.
I am looking for a way to insert the script text into the div, THEN run it without losing the script from the HTML.