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); });
Comments
Post a Comment