How ot Add Change Automatically Website Background?
Hello, aaj ki is post me me aapko btane wala hu ki aap apni website me Automatically change Background Kaise Laga Sakte hai iske liye liye aapko Source Code Chahiye agar aapko Code chahiye to neeche Aapko Code Download karne ka Button Show ho rha hoga us par click karke aap Code ko Download kar sakte hai .
This is Your Code
<script>
// Function to generate random hex color
function getRandomColor() {
return '#' + Math.floor(Math.random() * 16777215).toString(16);
}
// Function to set random gradient background and button color
function setRandomColors() {
var color1 = getRandomColor();
var color2 = getRandomColor();
var buttonColor = getRandomColor();
document.body.style.background = 'linear-gradient(to right, ' + color1 + ', ' + color2 + ')';
document.querySelector('.btn').style.backgroundColor = buttonColor;
}
// Change background and button color every 3 seconds
setInterval(setRandomColors, 3000);
</script>
Contact Us!
0 Comments
type your comment...