I'm trying to set a .click function for the first element with a certain class - and each one will need separate code, incrementing my purchase
function, with the first one using purchase(0,0,1);
and the second using purchase(0,1,1);
and so forth. While doing so with $(".generation:first")
(with generation being said class) works, I want to be able to do this for all elements with this class, referring to them from an array, and for some reason
$(".generation")[0].click(function () { purchase(0,0,1); });
doesn't work - no errors or anything. It just doesn't seem to select it. Just the same later:
// Note: listings is an array of three different classes, 0 is .generation
// Therefore, 'listings[0][0]' should be identical to '$(".generation")[0]'
listings[0][0].find(".count").text(game.buildings[type][id].count+" bought");
The above won't work, stating undefined is not a function
, if I use .children(".count")
it instead says object is not a function
.