Javascript examples for jQuery:Document
Dynamically generated script inserted to document
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.js"></script> <script type="text/javascript"> $(function(){// ww w . j a v a 2 s.c om $('#sLoad').click(function(){ $('<script/>').append( $('#script').html() ).appendTo('#script'); }); }); </script> </head> <body> <div id="script" style="display:none"> console.log(4+4); </div> <input id="sLoad" type="button" value="Load/Execute Script"> </body> </html>