CSS Method in jQuery

 <!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>CSS Method jQuery</title>
    <style>
        body {
            font-family: arial
        }

        #box {
            padding: 10px;
            border: 1px solid #000;
        }
    </style>
</head>

<body>
    <h1>jQuery CSS Methods</h1>
    <div id="box">
        <h2>Test Box</h2>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Provident aliquid consequuntur nobis itaque vero.
            Distinctio omnis harum aperiam animi facilis, cupiditate officia ipsa saepe nisi laborum beatae excepturi
            voluptatum neque.</p>
    </div>
    <br>
    <button id="stylebutton">Add Style</button>
    <script src="js/jquery-3.7.1.min.js"></script>
    <script>
        $(document).ready(function () {
            $("#stylebutton").click(function () {
                // $("#box").css("background", "brown");
                // $("h2").css("color", "white");
                // $("p").css("color", "white");
                //We can perform above code using below single line code as shown below:

                $("#box").css({ "background": "brown", "color": "white", "border": "5px dotted yellow" });
            });
        });
    </script>
</body>

</html>




Comments

Popular posts from this blog

Basic Syntax in jQuery

Event "Target" Property in jQuery