javascript background color change button code example
Example 1: javascript change color of button
document.getElementById("button").style.background='#000000';
Example 2: change background color on button click in javascript
<style>
.bg1 {
background-color: red;
}
</style>
<button id="btnChangebgColor" />
<script>
$(document).ready(function(){
$("#btnChangebgColor").click(function() {
$(this).addClass(".bg1");
});
}
</script>