I have a button whose background color i wanna change on a certain condition. When I use the ID it works, but not when i use the classname. Any ideas?
Button:
<a href="" class="btn btn-default" id="reset" onclick="reset();" style="width:150px; background-color:black; color:white;">Zurücksetzen</a>
Code:
... if(com == true && (IDs.length >= correctOrder.length))
{
document.getElementsByClassName('btn btn-default').style.backgroundColor = "green";
document.getElementById('messagewindow')
.innerHTML = 'Done!';
}else
{
document.getElementsByClassName('btn btn-default').style.backgroundColor = "red";
document.getElementById('messagewindow')
.innerHTML = 'Try again!';
}