The svg element tag does not support the addClass() and removeClass() methods in jquery
Solution
$.fn.addSvgClass = function(className) {
return this.each(function() {
var attr = $(this).attr('class')
if (attr) {
if (attr.indexOf(className) < 0) {
$(this).attr('class', attr + ' ' + className)
}
} else {
$(this).attr('class', className)
}
})
};
$.fn.removeSvgClass = function(className) {
return this.each(function() {
var attr = $(this).attr('class')
attr = attr.replace(' ' + className, '')
$(this).attr('class', attr1)
})
};
example
$('polygon').addSvgClass("be-selected")