How can I turn a string into a function?
FIDDle! How can I run my script stored in html? I dont want to take it out
of the function...
HTML:
<script type="hbrData">
function(){
var x = 22;
alert('hi');
}
</script>
JS:
var script = $('script[type="hbrData"]').text();
$('body').append(script);
script(); // Uncaught TypeError: string is not a function
No comments:
Post a Comment