I have an exemplary JavaScript code snippet. What I'm trying to achieve here is getting html, and id attribute value from an object within the array
var swatches = $(".swatchColor");
for (var i = 0; i < swatches.length; i++) {
var value = parseInt(swatches[i].html());
if (!isNaN(value)) {
alert(swatches[i].attr("id"));
}
};
but for some reason I get Uncaught TypeError: undefined is not a function error when swatches[i].html() is executed. Why does it happen?