animationIterationCount 속성은 애니메이션이 재생되는 횟수를 설정하거나 가져오는 데 사용됩니다.
구문
다음은 −
의 구문입니다.animationIterationCount 속성 설정 -
object.style.animationIterationCount = "number|infinite|initial|inherit"
값
다음은 값입니다 -
| Sr.No | 값 및 설명 |
|---|---|
| 1 | 숫자 애니메이션을 재생해야 하는 횟수를 나타내는 숫자 값입니다. 기본적으로 1로 설정됩니다. |
| 2 | 무한 이렇게 하면 애니메이션이 무한 재생됩니다. |
| 3 | 초기 이 속성을 초기 값으로 설정합니다. |
| 4 | 상속 상위 속성 값을 상속합니다. |
예시
animationIterationCount 속성의 예를 살펴보겠습니다 -
<!DOCTYPE html>
<html>
<head>
<style>
p {
color: black;
animation: shrink 3s;
animation-timing-function: ease;
animation-iteration-count: 1;
}
@keyframes shrink {
0% {
color: white;
letter-spacing: 1.8em;
}
100% {
color: magenta;
letter-spacing: 0.01em;
}
}
</style>
<script>
function IncreaseIteration(){
document.getElementById("PARA1").style.animationIterationCount=5;
document.getElementById("Sample").innerHTML="The animation Iteration count is now 5";
}
</script>
</head>
<body>
<p id="PARA1">Tellus elementum sagittis vitae et. Ac orci phasellus egestas tellus rutrum tellus pellentesque.</p>
<p>Click the below button to change how many times the above animation will run</p>
<button onclick="IncreaseIteration()">INCREASE COUNT</button>
<p id="Sample"></p>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

좌표 버튼을 클릭하고 "내 위치 알기" 팝업에서 허용을 클릭하면 -
