I have an svg map image and I want to loop over it's path element and add add a class. I get the above error nonetheless. Here is my code
document.addEventListener("DOMContentLoaded", function() {
svg = document.getElementsByTagName('path');
for(i=0; i<svg.length;i++)
{
svg[i].addEventListener('mouseover', function(){
svg[i].setAttribute('class','svgclass');
});
}
});
WHat am i doing wrong? Thanks