Answers for "html background toggle image changer"

0

html background toggle image changer

<button onclick="myFunction1()" style="background-color: white; padding: 2px; border: none;">Toggle light mode</button>


<style>
  body{
  	background-color: white;
  }

	.dark-mode{

    background-image: url("image.jpg");
    color: white;

}

</style>

<script>
	<script>
function myFunction1() {
   var element = document.body;
   element.classList.toggle("dark-mode");
}
</script>
Posted by: Guest on July-26-2021

Browse Popular Code Answers by Language