JS 관련/JQuery
[jQuery] 이펙트 메서드( animate() )
씨네
2022. 2. 19. 12:08
728x90

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
a{font-weight: bold; color: #000000;}
#box{background: skyblue; width: 100px; height: 100px; position: relative;}
</style>
<script type="text/javascript" src="resources/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript">
$(function(){
$(".run").click(function(){
$("#box").animate({opacity: "0.1", left: "400px"}, 1000)
.animate({opacity: "0.4", top: "160px", width: "20px", height: "20px"}, "slow")
.animate({opacity: "1", left: "0px", width: "100px", height: "100px"}, "slow")
.animate({top: "0px"}, "fast")
.slideUp()
.slideDown("slow");
});
});
</script>
</head>
<body>
<p><a href="#" class="run">Run</a></p>
<div id="box"></div>
</body>
</html>

해당 코드는 animate 효과를 순차적으로 줘서 애니메이션처럼 움직이는 코드입니다.

사각형이 움직여요!
728x90