<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.13.2/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js"></script>
<style type="text/css">
#box {
width: 150px;
height: 150px;
background: orange;
margin-bottom: 20px;
position: relative;
top: 0;
left: 0;
}
</style>
</head>
<body>
<h1>Effect - Animate</h1>
<hr>
<select id="easing">
<option>linear</option>
<option>easeInCubic</option>
<option>easeOutCubic</option>
<option>easeInBack</option>
<option>easeOutBack</option>
<option>easeInElastic</option>
<option>easeOutElastic</option>
</select>
<hr>
<div id="box"></div>
<button type="button" id="left">◀</button>
<button type="button" id="right">▶</button>
<script type="text/javascript">
$("#left").attr("disabled", "disabled");
$("#left").click(function() {
var easing=$("#easing").children(":selected").text();
$("#left").attr("disabled", "disabled");
$("#right").removeAttr("disabled");
$("#box").stop().animate({"left":0}, 3000, easing);
});
$("#right").click(function() {
var easing=$("#easing").children(":selected").text();
$("#right").attr("disabled", "disabled");
$("#left").removeAttr("disabled");
$("#box").stop().animate({"left":$(window).width()-170}, 3000, easing);
});
</script>
</body>
</html>