Detecting classname of SVGAnimatedString

前端 未结 2 1309
生来不讨喜
生来不讨喜 2021-02-18 16:12

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) {
               


        
相关标签:
2条回答
  • 2021-02-18 16:52

    Simplest way:

    e.target.className.baseVal
    

    Another way:

    e.target.getAttribute("class")
    
    0 讨论(0)
  • 2021-02-18 16:52

    Make sure you also set the class name inside the svg path tags and then try e.target.getAttribute("class")

    That worked for me.

    0 讨论(0)
提交回复
热议问题