Q:

Using jQuery animates the first div's left property and synchronizes the remaining divs

0

Using jQuery animates the first div's left property and synchronizes the remaining divs.

Note: Use the step function to set their left properties at each stage of the animation.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Animates the first div's left property and synchronizes the remaining divs.</title>
</head>
<body>
<p><button id="run">Click to Run »</button></p>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
</body>
</html>

CSS Code:

div {
    position: relative;
    background-color: #B0E0E6;
    width: 45px;
    height: 45px;
    float: left;
    margin: 5px;
  }

JavaScript Code :

$( "#run" ).click(function() {
  $( ".block:first" ).animate({
    left: 100
  }, {
    duration: 2000,
    step: function( now, fx ){
      $( ".block:gt(0)" ).css( "left", now );
    }
  });
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now