animate Method (For Animations) in jQuery

 <!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animate Method</title>
    <style>
        #box {
            background: #90ee90;
            padding: 10px;
            border: 1px solid #000000;
            width: 100px;
            height: 100px;
            position: relative;
        }
    </style>
</head>

<body>
    <h1>jQuery Animate Method</h1>
    <div id="box">Yahoo Baba</div>
    <br>
    <button id="animateBtn">Animate</button>
    <script src="js/jquery-3.7.1.min.js"></script>
    <script>
        $(document).ready(function () {
            $("#animateBtn").click(function () {
                // $("#box").animate({
                //     left: "150px",
                //     // width: "200px"
                //     // width: "+=200px",   //This 200px width will increase in its normal width applied in CSS, this means that width will apply 100px + 200px = 300px
                //     // width: "hide",
                //     width: "toggle",
                //     fontSize: "40px",
                //     borderWidth: "5px"

                // });


                //Below is Animation Queue Effect
                $("#box").animate({ left: "150px", fontSize: "40px" }, 3000, function () {
                    console.log("First Animation Completed");
                });
                $("#box").animate({ top: "150px" });
                $("#box").animate({ width: "250px" });
            });
        });
    </script>
</body>

</html>




Comments

Popular posts from this blog

Basic Syntax in jQuery

Event "Target" Property in jQuery