Answers for "how to change color on button click"

CSS
1

change button color html

.button {
  background-color: #4CAF50;
}
Posted by: Guest on May-07-2021
1

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>
Posted by: Guest on March-17-2021

Code answers related to "how to change color on button click"

Browse Popular Code Answers by Language