I want to change my list background but it wont work
my code :
change(num, element){
var text
if (num == 1){ ... }
else if (num == 2) { ... }
else { ... }
document.getElementById('text').innerHTML = text;
document.getElementByClass("left").style.backgroundColor = "black"; //<------
element.style.backgroundColor = "white"; //<------
}
and my html :
<ul>
<li><a class="left" href="#" onclick="change(1,this)>First</a></li>
<li><a class="left" href="#" onclick="change(2,this)>Second</a></li>
<li><a class="left" href="#" onclick="change(3,this)>Third</a></li>
</ul>
When i click on one of my list element , the text changes but background color won't ...
How i can fix this ?
Thanks,