Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find class name of SVG element

How can I find the class name of SVG attribute?

If it was div it would have been {reference to DIV}.className

But, this doesnt work exactly the same way with SVG element

Is there any jquery or javascript method/attribute to get the classes of a SVG element?

See below what I have tried:

enter image description here

like image 375
Cute_Ninja Avatar asked Jun 26 '14 18:06

Cute_Ninja


1 Answers

Here's a jsfiddle: http://jsfiddle.net/Ujp76/

<body>
   <svg class="c1"></svg>

   <script>
      window.addEventListener("load", function () {
          var className = document.querySelector("svg").getAttribute("class");
          console.log(className);
      });
   </script>
</body>
like image 86
mdlars Avatar answered Nov 10 '22 14:11

mdlars