Sohaib Mohammed Sohaib Mohammed - 11 months ago 83
Javascript Question

vivus.js - How to select SVG by Class

Is there a way to select SVG by Class instead of ID , Like this:

<svg class="mySVG">

new Vivus('.mySVG', {duration: 200}, myCallback);

Answer Source

Since you can have multiple elements with same class

  var els= document.getElementsByClassName("mySVG");

  for (var i = els.length - 1; i >= 0; i--) {
    new Vivus(els[i], {duration: 200}, myCallback);