How To Use Queue Functionality For Animations In JQuery

admin_img Posted By Bajarangi soft , Posted On 13-10-2020

In JQuery by default, jQuery comes with queue functionality for animations.So today we discuss how to do it

How To Use Queue Functionality For Animations In JQuery

Step 1:Create index.html file and implement below code.

<button class="btn-success">Start Animation</button>
<br><br><br>
<p style="background:#98bf21;height:100px;width:100px;position:absolute;"></p>


Step 2:Implement jquery to Use Animation with queue functions.

<script>
    $(document).ready(function(){
        $("button").click(function(){
            var div = $("p");
            div.animate({height: '300px', opacity: '0.4'}, "slow");
            div.animate({width: '300px', opacity: '0.8'}, "slow");
            div.animate({height: '100px', opacity: '0.4'}, "slow");
            div.animate({width: '100px', opacity: '0.8'}, "slow");
        });
    });
</script>


Complete Code For Using Queue Functionality For Animations In JQuery

<!DOCTYPE html>
<html>
<head>
    <title>How To Use Queue Functionality For Animations In JQuery</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<style>
    body {
        background: darkolivegreen;
    }
    .well{
        height:210px;

    }
</style>
<body>
<div class="container">
    <br><br><br>
    <div class="text-center">
        <h2 id="color" style="color: White">Queue Functionality For Animations In JQuery</h2>
    </div>
    <br>
    <br>

    <div class="well">


        <button class="btn-success">Start Animation</button>
        <br><br><br>
        <p style="background:#98bf21;height:100px;width:100px;position:absolute;"></p>

    </div>

</div>
</body>
</html>
<script>
    $(document).ready(function(){
        $("button").click(function(){
            var div = $("p");
            div.animate({height: '300px', opacity: '0.4'}, "slow");
            div.animate({width: '300px', opacity: '0.8'}, "slow");
            div.animate({height: '100px', opacity: '0.4'}, "slow");
            div.animate({width: '100px', opacity: '0.8'}, "slow");
        });
    });
</script>

Related Post