#Change Span Text Color

2 messages · Page 1 of 1 (latest)

steep mountain
#

I'm trying to change the color of some <span> items which all contain the class dsm-menu-text using JS. They're inside a div with id navbar. How can I select them? I tried

const menuText = document.getElementById("navbar").getElementsByClassName("dsm-menu-text");
menuText.style.setProperty("color", "#014e8c", "important");

but that doesn't seem to work.

The CSS that sets the color in the stylesheet is:

.dsm_mega_menu_0_tb_header .dsm-mega-menu-container .dsm-root-menu .dsm-mega-menu-item .dsm-menu-text {
  color:#FFFFFF
}```
jade urchin
#

getElementsByClassName returns an array like collection you need to loop over