jQuery SVG, why can't I addClass?

前端 未结 15 1857
失恋的感觉
失恋的感觉 2020-11-22 02:25

I am using jQuery SVG. I can\'t add or remove a class to an object. Anyone know my mistake?

The SVG:



        
15条回答
  •  再見小時候
    2020-11-22 02:42

    There is element.classList in the DOM API that works for both HTML and SVG elements. No need for jQuery SVG plugin or even jQuery.

    $(".jimmy").click(function() {
        this.classList.add("clicked");
    });
    

提交回复
热议问题