Answers for "get element class"

62

javascript get element by class

var elementsArray = document.getElementsByClassName("someclassname");
Posted by: Guest on June-17-2019
0

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';
    }
}
Posted by: Guest on July-15-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language