javascript - Adding Html using innerHTML property doesn't fire jQuery ready event -


i having performance issues using .html() method of jquery because being slow. searched alternatives , found some:

so replacing .html() method suggested. have problem:

javascript inside html added not being executed.

i have written simple fiddle show happening:

can suggest how solve because need javascript executed.

you might need eval() script:

var container = document.getelementbyid("container"),     content = document.getelementbyid("content");  $("#button2").on("click", function(){     container.innerhtml = content.innerhtml;     var scripts = container.getelementsbytagname('script');     for(var i=0, l=scripts.length; i<l; i++) eval(scripts[i].innertext); }); 

js fiddle demo


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -