Im trying to grab my divs with the class tooltip.
And then do something like this:
var schemes = $(".tooltip");
for (var i in schemes) {
var scheme = schemes[i];
console.log(scheme.attr("cost"));
}
But it throws the above error. What am i missing? (Im new to javascript + jquery obviously)
If you use
for-loopto iterate jQuery set, you should get the elements witheq()method, but not using square bracket notation (i.e.[]). The code like$(".tooltip")[i]will pick up DOM elements, but not jQuery objects.However, you may always use
each()to iterate jQuery set: