Using jQuery animates the first div's left property and synchronizes the remaining divs
- جي كويري
- 2021-09-17
- mhanasmh00489829403
الأجوبة
<!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 );
}
});
});
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة