我研究了一些我将概述的方法。将不胜感激有关哪个最好的进一步评论。目标是从生成的源中隐藏“onClick”侦听器。
document.getElementById('ID').addEventListener('click',function();,false);
//Problems: Has to be terminated and false/true is something tricky I don't understand yet (please see link I post)
document.getElementById('ID').onclick = function();
//Problems: Cannot be terminated directly and heirachy issue where function including 'this' keyword applies to the child divs or something (please again see link I post)
//an iterartion of setInterval(checkFunction,interval);
//Problems: Very very slow and in most cases requires an onClick to check for a change anyway!
因此,在我的研究结束时,这个网站因很好地解释了 Java 中的 eventListeners 如何有效地被钩住而脱颖而出:http: //www.howtocreate.co.uk/tutorials/javascript/domevents