Without jQuery, this snippet will save every a that it can find in every li in the main menu. Then it will go through each element and set the text color to red .
var a_list = document.querySelectorAll('#main-menu li a'); for (var i=0; i<a_list.length; i++) { a_list[i].style.color = 'red'; }
If you use jQuery, you can do the same thing:
$('#main-menu li a').css('color','red');
However, keep in mind that it is not recommended to set style rules using JavaScript, as this is what CSS was designed for. It would be much better if you used JavaScript to add a class (perhaps something like .higlighted-text ) to your a elements, which therefore behave as you wish.
source share