Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get class name of element in javascript

var spans = document.getElementsByTagName("span");
for (var i = 0; i < spans.length; i++) {
    if (spans[i].className == 'xyz') {
        spans[i].style.backgroundColor = '#000';
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #class #element #javascript
ADD COMMENT
Topic
Name
7+5 =