Here I have written a JavaScript
to change color of button to green when clicked once and when I click the button again its color should change back to orange color. The default color of button is orange. I have given the rgb
values of color. But, when I click the button its color changes from orange to green and when I click it again its color remains green doesn't change back to orange. please help me to fix this.
<script>
function colorchange(id)
{
var background = document.getElementById(id).style.background;
if(background = "rgb(255,145,0)")
{
document.getElementById(id).style.background = "rgb(26,255,0)";
}
if(background == "rgb(26,255,0)")
{
document.getElementById(id).style.background = "rgb(255,145,0)";
}
}
</script>
Here is the HTML code for input button
<input type="button" name="Ignore Select" value="Ignore Select" id="select" onclick="colorchange('select')" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Delete" value="Ignore Delete" id="select1" onclick="colorchange('select1');" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Insert" value="Ignore Insert" id="select2" onclick="colorchange('select2');" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Update" value="Ignore Update" id="select3" onclick="colorchange('select3');" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Sleep" value="Ignore Sleep" id="select4" onclick="colorchange('select4');" style="background:rgb(255,145,0);"/>