Sohaib Mohammed Sohaib Mohammed - 1 year ago 169
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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download