jQuery animate() animate with relative values

Description

jQuery animate() animate with relative values

View in separate window

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example of jQuery Animation with Relative Values</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<style>
    .box{//from  www .  ja  v a2  s . c o m
        width: 100px;
        height: 100px;
        background: #9d7ede;
        margin-top: 30px;
        position: relative; /* Required to move element */
    }
</style>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $(".box").animate({
            top: "+=50px",
            left: "+=50px",
            width: "+=50px",
            height: "+=50px"
        });
    });
});
</script>
</head>
<body>
    <button type="button">Start Animation</button>
    <div class="box"></div>
</body>
</html>



PreviousNext

Related