I am trying to create a clone of jsbin or jsfiddle. I have written a javascript function which ammends code to the HTML when the run button is clicked. The HTML and CSS code updates and runs fine but I cannot seem to get the javascript to work. I am trying to get an alert('hello world')
to pop up when I press the run button
The following is the javascript code
document.getElementById("run").onclick=function(){
var x = document.getElementById('updateable');
var html= "<p>Hello World</p>";
var css="<style>p {color:green;}</style>";
var js="<script> alert('hello world') <\/script>";
x.innerHTML=html + css +js;
}
https://jsfiddle.net/7oskp4wa/2/
I have included my jsfiddle and hope it helps