The accepted answer seems to me wrong. Firstly, it does not take into account newdiv containing child elements, therefore, the proposed removal procedure prevents memory leak through locks (IE). Secondly, because of the position "newdiv = null", the created function immediately destroys the newly created element. I would recommend using the Douglas Crockfords cleanup function for the click handler, replacing d with this.
function purge(d) { var a = d.attributes, i, l, n; if (a) { l = a.length; for (i = 0; i < l; i += 1) { n = a[i].name; if (typeof d[n] === 'function') { d[n] = null; } } } a = d.childNodes; if (a) { l = a.length; for (i = 0; i < l; i += 1) { purge(d.childNodes[i]); } } }
Kooiinc
source share