how to change button color:
single button change a double color.
sample program:
<html>
<head>
<style>
.red{ background: red; border: 0px; }
.green { background: green; border: 0px; color: #fff; }
</style>
<script>
function controls(className)
{
if (className == "red")
{
document.getElementById('OnOff').setAttribute('class','green');
document.getElementById('OnOff').innerHTML = "ON";
} else
{
document.getElementById('OnOff').setAttribute('class','red');
document.getElementById('OnOff').innerHTML = "OFF";
}
}
</script>
</head>
<body>
<button id="OnOff" name="OnOff" class="red" onclick="controls(this.getAttribute('class'))">OFF</button>
</body>
</html>
single button change a double color.
sample program:
<html>
<head>
<style>
.red{ background: red; border: 0px; }
.green { background: green; border: 0px; color: #fff; }
</style>
<script>
function controls(className)
{
if (className == "red")
{
document.getElementById('OnOff').setAttribute('class','green');
document.getElementById('OnOff').innerHTML = "ON";
} else
{
document.getElementById('OnOff').setAttribute('class','red');
document.getElementById('OnOff').innerHTML = "OFF";
}
}
</script>
</head>
<body>
<button id="OnOff" name="OnOff" class="red" onclick="controls(this.getAttribute('class'))">OFF</button>
</body>
</html>
No comments:
Post a Comment