I have not tested this in all browsers, but if you don't want to introduce any new js framework, this solution uses only CSS:
<ul> <li tabindex="1">First</li> <li tabindex="2">Second</li> </ul>
The tabIndex property makes the li element focused. And css:
li { color: #F00; } li:focus { color: #0F0 }
This, of course, is a very simple style, perhaps you need to put it in classes or something else.
source share