javascript change color of button onclick code example
Example 1: javascript change color of button
document.getElementById("button").style.background='#000000';
Example 2: onclick change text color javascript
<script>
document.getElementById('change').onclick = changeColor;
function changeColor() {
document.body.style.color = "purple";
return false;
}
</script>
Example 3: javascript change button onclick
function Bar() {
document.getElementById("a").onclick = Foo();
}