Binary World

jQuery 애니메이션(animate) 01 본문

개발자의 길/jQuery

jQuery 애니메이션(animate) 01

모쿠 2017. 4. 11. 09:52

<animate() 함수를 이용한 애니메이션 효과>


* animate 함수 포멧

- animate(params, speed, callback)

-   params: 애니메이션을 할 속성들(JavaScript Object)


* 애니메이션 함수들

- hide(speed, callback), fadeOut(speed, callback), slideUp()

- show(speed, callback), fadeIn(speed, callback), slideDown()

- toggle(speed, callback), fadeToggle(spped, callback), slideToggle()


<09_animate.html>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery</title>
<style>
#panel {
    border: 1px solid grey;
    background-color: lime;
    width: 200px;
    height: 200px;
    
}
</style>
</head>
<body>
 
<h1>jQuery 애니메이션 함수들</h1>
<button type="button" id="btn1">Hide</button>
<button type="button" id="btn2">Show</button>
<button type="button" id="btn3">Toggle</button>
<div id="panel">Animation</div>
 
<!-- jQuery CDN 포함: 라이브러리 포함 -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script>
$(document).ready(function() {
    $('#btn1').click(function(){
        $('#panel').slideUp(3000);
    });
    $('#btn2').click(function(){
        $('#panel').slideDown(3000);
    });
    $('#btn3').click(function(){
        $('#panel').slideToggle(3000);
    });
    
});
</script>
</body>
</html>
cs



<10_animate.html>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery</title>
<style type="text/css">
#panel {
    border: 1px solid grey;
    background-color: lime;
    width: 100px;
    height: 100px;
    position: relative
}
</style>
</head>
<body>
 
<h1>jQuery animate() 함수</h1>
<button type="button" id="btn1">위치 이동</button>
<div id="panel">jQuery animate</div>
 
<!-- jQuery CDN 포함: 라이브러리 포함 -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script>
$(document).ready(function() {
    $('#btn1').click(function() {
        $('#panel').animate({left: '300px', top:'300px', fontSize: '200%', opacity: '0.5'}, 3000);
    });
});
</script>
 
</body>
</html>
cs



<출력화면>


- 09_animate.html





- 10_animate.html





'개발자의 길 > jQuery' 카테고리의 다른 글

jQuery 반복문(each)  (0) 2017.04.10
jQuery CSS 변경  (0) 2017.04.10
jQuery getter/setter  (0) 2017.04.10
jQuery 이벤트(event) 02  (0) 2017.04.10
jQuery 이벤트(event) 01  (0) 2017.04.10
Comments