I need to compare all the selected attribute with variants on the AliExpress site.But my code is checking for only first key and adding class but when its come to 2nd and 3rd class its look like its not checking for them.I tried using length property but it says length is undefined.
function selectAttributes() {
chrome.storage.local.get(null, function(result) {
for (i = 0; i < result.ae_items.length; i++) {
console.log(result.ae_items[i].attributes);
for (var key in result.ae_items[i].attributes) {
$(".sku-property-list").each(function() {
$(".sku-property-item").each(function() {
if ($(this).has("img")) {
var title = $(this).children(".sku-property-image").children("img").attr("title");
if (title == result.ae_items[i].attributes[key]) {
$(this).addClass("selected");
}
} else {
var title = $(this).children(".sku-property-text").children("span").text();
alert(title);
}
});
});
}
}
});
}