How can i change the css of my menu link, using javascript?
<li>
<a href="here is the link">
Промоции </a>
</li>
Because i cant add id on <li>
or <a>
! Im using opencart, and im just trying to modify a theme
How can i change the css of my menu link, using javascript?
<li>
<a href="here is the link">
Промоции </a>
</li>
Because i cant add id on <li>
or <a>
! Im using opencart, and im just trying to modify a theme
For all menu links,
// CSS Code
.custom_style { color: red; }
// JS Code
const links = document.querySelectorAll('li a');
for(var i = 0; i < links.length; i++) {
links[i].classList.add('custom_style');
}
For single menu link,
// CSS Code
.custom_style { color: red; }
// JS Code
const link = document.querySelector('li a');
link.classList.add('custom_style');