I am not so experienced with JavaScript yet, so Im probably didn’t notice something here:
var products = document.getElementsByClassName('product');
var productsLength = products.length;
for(var i = 0; i < productsLength; i++){
var productGender = products[i].attr('data-gender');
if(productGender === triggerVal){
console.log('yes');
} else {
console.log('no');
}
};
It says: products[i].attr
not a function
Should I have access to it correctly? The product is only a list item.
Thanks!
source
share