I am looking to switch the "fill: #000;" from the CSS property "svg [id^='_']".
Usually, I would use a method like this, but it seems that I can't do so because "svg [id^='_']" is not an element, correct?
pub.toggleClass = function(el, className) {
if (el.classList) {
el.classList.toggle(className);
} else {
var classes = el.className.split(' ');
var existingIndex = classes.indexOf(className);
if (existingIndex >= 0)
classes.splice(existingIndex, 1);
else
classes.push(className);
el.className = classes.join(' ');
}
};
However, when attempting to toggleClass, I encounter the error "Uncaught TypeError: Cannot read property 'split' of undefined"...
My attempt at using
document.styleSheets[1].addRule("svg [id^='_']", 'fill: #000;');
has not been effective across different browsers and is failing to toggle... Could there be a simpler solution for this task?
Update 1
I will experiment with this library: https://github.com/Box9/jss