I have this textbox. When a user writes some Jquery code in the textbox and click Apply. I want the code applied to Html page. The code is being appended to body but the generated click function is not working. I have also tried appending the code to HEAD also, click doen't work this way too. Is it possible that it works?
My Html code is
<span id="clickme">Click Me</span>
<textarea id="txt">
$('#clickme').click(function(){
alert("clicked");
});
</textarea>
<button id="apply">Apply</button>
My Jquery is
$(document).ready(function(){
$(document).on('click','#apply',function(){
var code=$('#txt').val();
$('body').append('<script type="text/javascript">'+code+'</script>');
});
});
eval.