Javascript examples for jQuery Method and Property:append
Append javascript script to head
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.js"></script> </head> /*from ww w . ja va2 s . co m*/ <body> <a href="javascript:void(0)">CLICK</a> <script type="text/javascript"> $(document).ready(function () { $('a').on('click', function () { $('<script>').text('test()').appendTo('head'); }); }); function test(){ console.log("running") } </script> </body> </html>