Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.0 kB
1
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Color Changer App</title>
<style>
    body {
        font-family: Arial, sans-serif;
        text-align: center;
    }
    #container {
        margin-top: 100px;
    }
    #colorButton {
        padding: 10px 20px;
        font-size: 18px;
        cursor: pointer;
    }
</style>
</head>
<body>

<div id="container">
    <h1>Color Changer App</h1>
    <button id="colorButton">Change Color</button>
</div>

<script>
    document.getElementById('colorButton').addEventListener('click', function() {
        changeColor();
    });

    function changeColor() {
        var colors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00', '#ff00ff', '#00ffff'];
        var randomColor = colors[Math.floor(Math.random() * colors.length)];
        document.body.style.backgroundColor = randomColor;
    }
</script>

</body>
</html>
Leave a Comment