Answer the question
In order to leave comments, you need to log in
How to addClass to svg element?
There is svg-ha (this is, if you're interested, a map of the city). When I click on a map segment (it has the .region class ), I want the .active class to be added to it . On the screen itself svg and jquery code.
But for some reason, the class does not want to be added to this case, despite the fact that the object comes to $ (this).
Console screenshot:
What needs to be done so that it still adds a class to the map segment?
Answer the question
In order to leave comments, you need to log in
I suffered for a long time with this crap ... As a result, I was able to master it by:.attr("class", "your classname")
Try using the jQuery attr() function or js native setAttribute() and classList .
I literally struggled with this issue today as well. attr() method only saves. No other way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question