คุณสมบัติ 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> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -

เมื่อคลิกปุ่มประสานงานและคลิกอนุญาตในป๊อปอัป "รู้จักตำแหน่งของคุณ" -
