I'm trying to change the background-color
property of a button using JavaScript. The script checks what the current background-color
is set to and then toggles it.
This is the JavaScript code:
function btnColor(btn,color) {
var property=document.getElementById(btn);
if (property.style.background-color == "#f47121") {
property.style.background-color=Color;
}
else {
property.style.background-color = "#f47121";
}
}
and this is what I pass in html:
<input type="button" id="btnHousing" value="Housing" onclick="toggleLayer('transparent1');btnColor('btnHousing','#fff200');" />
toggleLayer
is another function I am using, which works perfectly fine.
I can't seem to figure out why it doesn't work.