I want to have 5 lists such than when any of them is clicked, it turns to green and turn the other lists to black if any of them is green.
Here\'s m
Here is code without using any library or frameworks. You can acheive this using javascript.
- one
- two
- three
- four
- five
Script goes here ....
function myFunction(e) {
var elems = document.querySelector(".active");
if(elems !==null){
elems.classList.remove("active");
}
e.target.className = "active";
}
css goes here....
li.active {
color: green;
}