Reputation: 365
I would like to add an Event Handler for all of my <td>
tags. I've tried the following:
var allSquares = document.getElementsByTagName("td");
for (var i = 0, len = allSquares.length; i < len; i++){
allSquares[i].addEventListener('ondragover', allowDrop, false);
}
Anyone has an idea why it didn't work? Thanks ahead
Upvotes: 0
Views: 67
Reputation: 664548
With the W3-method addEventListener
you don't put an "on"
before the event's name (like you do for Microsoft):
allSquares[i].addEventListener('dragover', allowDrop, false);
See Quirksmode's article on the two advanced event registration models.
Upvotes: 1
Reputation: 48761
Generally event names passed to addEventListener
do not start with "on"
.
allSquares[i].addEventListener('dragover', allowDrop, false);
Upvotes: 2