Reputation: 9
My project doesn't alert "Test" when I click on any of the "td" Elements.
I will use it for something more useful later but I'm just trying to get it to alert on click, Thank you!
link: http://jsfiddle.net/gk5c9z2z/
$("td").click(function () {
alert("Test");
});
Upvotes: 0
Views: 293
Reputation: 144689
for (var i = 0; i <= Cards.length; 0) {
line is the culprit. The last iteration fails as Cards[i]
returns undefined
and undefined
doesn't have setAttribute
method. JavaScript interpreter throws an error and subsequent lines are not executed. Change it to:
for (var i = 0; i < Cards.length; 0) {
Also note that you could use i++
instead of 0
as the final-expression of the for
loop and remove the i = i + 1;
line.
Upvotes: 3
Reputation: 488
I think you should use
$("td image")
as you are really clicking on the image.
Upvotes: 0