console
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Background Image Switcher</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
#background-switcher {
width: 945px;
height: 1083px;
background-image: url('https://i.postimg.cc/cCVRypkz/bg1.png');
background-size: cover;
background-position: center;
transition: background-image 0.5s ease-in-out;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
#switch-button {
margin-top: 20px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
transition: background-color 0.3s;
}
#switch-button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div id="background-switcher"></div>
<button id="switch-button">Switch Background</button>
<script>
const backgroundSwitcher = document.getElementById('background-switcher');
const switchButton = document.getElementById('switch-button');
let isImageOne = true;
const image1 = 'https://i.postimg.cc/cCVRypkz/bg1.png';
const image2 = 'https://i.postimg.cc/C5ZG2h7D/bg2.png';
switchButton.addEventListener('click', () => {
if (isImageOne) {
backgroundSwitcher.style.backgroundImage = `url('${image2}')`;
} else {
backgroundSwitcher.style.backgroundImage = `url('${image1}')`;
}
isImageOne = !isImageOne;
});
</script>
</body>
</html>