Applying an event handler to elements through a loop in Javascript
<p>I would like to add an Event Handler for all of my <code>&lt;td&gt;</code> tags. I've tried the following:</p>

<pre><code>var allSquares = document.getElementsByTagName("td");

for (var i = 0, len = allSquares.length; i &lt; len; i++){
allSquares[i].addEventListener('ondragover', allowDrop, false);

}
</code></pre>

<p>Anyone has an idea why it didn't work?
Thanks ahead</p>
