Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting classname of SVGAnimatedString

Tags:

I had a problem with a SVG map I was building, the functions triggered by onmouseover on g were not working. I used then

window.onmouseover=function(e) {             console.log(e.target.className);         }; 

to see if there was any problem with the classname, and then discovered than instead of the classname I was using, the system was detecting

SVGAnimatedString {animVal: "", baseVal: ""} 

Something that never happened to me before the hundreds of times I've used similar code. Any idea how can I get the actual classname of the g elements on mouseover? Thanks

like image 577
Chiqui Esteban Avatar asked Apr 05 '15 05:04

Chiqui Esteban


1 Answers

Simplest way:

e.target.className.baseVal 

Another way:

e.target.getAttribute("class") 
like image 68
radiaph Avatar answered Sep 17 '22 16:09

radiaph