Created
December 1, 2016 20:23
-
-
Save EliJDonahue/0a858c9291cecbfd90bf26dad9858cc5 to your computer and use it in GitHub Desktop.
Add a custom CSS class to a collection of elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ////////////////////// Helpful functions /////////////////////////////////// | |
| // appends a value to an attribute for all elements in a collection | |
| // can be used to append class name | |
| appendAttributeOnAll = function(els, attrName, attrVal) | |
| { | |
| for (var i=0; i < els.length; i++) | |
| { | |
| var curr = els[i].getAttribute(attrName); | |
| els[i].setAttribute(attrName, curr + ' ' + attrVal); | |
| } | |
| }; | |
| ////////////////////// Override default styles ///////////////////////////// | |
| // inline label style | |
| appendAttributeOnAll(labels,'class','my_label'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment