Koneksi internet anda terputus. Tunggu dan coba lagi , atau Refresh Halaman.

change backround color using jquery




 html code:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
</head>
<body>
    <div class="container">
        <div class="div1">
            Enter your hash:
        </div>
        <div class="div2">
            <input type="text" id="clr" class="input">
        </div>
    </div>
    <script src="script.js"></script>
</body>
</html>

css code:

*{
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

body{
    background-color: black;
    display: flex;
    justify-content: center;
}

.div1{
    margin-top: 10px;
}
.container{
    color: white;
    border: 2px solid white;
    width: 50%;
    height: 30vh;
    display: grid;
    justify-content: center;
    border-radius: 10px;
    margin-top: 20vh;
}
.input{
    height: 10vh;
    font-size: 4vh;
    border-radius: 10px;
}

jquery code:

$(document).ready(function() {
    $('#clr').keyup(function() {
        $('body').css("background-color", this.value);
    });
});


Previous
Next Post »