I'm trying to select an element with JavaScript using the following snippet of code inside an AngularJS application.
var assicurazione = document.getElementsByClassName("assicurazione");
var aLength = assicurazione.length;
for(var key in assicurazione){
console.log("key: ", key);
console.log("assicurazione[key] ", assicurazione[key]);
}
console.log("assicurazione element: ", assicurazione);
console.log("assicurazione.length: ", aLength);
for(var a = 0; a < aLength; a++){
console.log("Element: ", assicurazione[a]); // not firing
console.log("a value: ", a); // not firing
}
The output of the console.log is the following:
The loop is not working as expected because the length is 0, but the element has a length property and in this case it is set to 16 so I have no idea why it wouldn't loop through the element.
Anyone that can help me?