specify your id style tag, for example <style id="ssID"> if someonelse does your styles for you tell this person to give an id style tag - this way you can access it directly without scrambling around, wondering what it is index
now you have a hash table for everything contained in the stylesheet - note that some values ββwill be undefined, but not for any of the things you care about
if you have, for example, a class named #menuItem and you want to change your color to black, do this
cssHash['#menuItem'].style.color =
this line sets the color of the rule style whose index was viewed in the hash table (cssHash) named "#menuItem"
more importantly, you probably have several different classes that you want to change right away, sort of like when you changed majors in college
let's say you have four different classes and you want to set all background colors to the same value as some user selected from input
the color selector tag <input id="bColor" type="color"> and the class rules you want to change are called #menuItem. homeAddr span and #vacuum: hover
// create a listener for that color selector bColor.addEventListener('input', function (e) { // loop through a split list of the four class names '#menuItem .homeAddr span #vacuum:hover'.split(' ').forEach(function (obj) { // use the hash table to look up the index of each name // and set the background color equal to the color input value cssHash[obj].style.backgroundColor = bColor.value; }); }, false); // false added here for the sake of non-brevity
stoke motor Apr 22 '17 at 3:53 on 2017-04-22 03:53
source share