javascript - Why is it suggested to avoid .innerHTML? -


sorry being javascript noob, can please explain why recommended not use .innerhtml. when have faster , easier in form of .innerhtml , why shouldn't use ?

innerhtml sledgehammer. blast away contents of selected dom element , replace them whatever happens assigned @ time. leads number of html escaping , validation issues.

more importantly, pages large number of events bound, using innerhtml append element regenerate dom elements, means event bindings can lost.

there issues regarding memory leaks in older versions of ie when elements removed dom.


with of said, i'm not telling you shouldn't using innerhtml. use time in jquery when use $(selector).html(). sledgehammer right tool job, , when events delegated won't matter how content reloaded.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -