animation-iteration-count: value; object.style.animationIterationCount = "value"; <'animation-iteration-count'> = <single-animation-iteration-count># <single-animation-iteration-count> = infinite | <number> infinite The animation will repeat forever.
<number> An integer or zero or more decimal digits followed by a dot (.) followed by one or more decimal digits. The first character may be preceded by a sign (- or +). The last character may be succeeded by an exponent (e or E) and an integer.
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
margin-left: 0;
}
100%
{
margin-left: 200px;
}
}
p
{
animation-duration: 4s;
animation-iteration-count: 4;
animation-name: mykeyframes;
}
</style>
</head>
<body>
<p>number</p>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
margin-left: 0;
}
100%
{
margin-left: 200px;
}
}
p
{
animation-duration: 4s;
animation-name: mykeyframes;
}
</style>
</head>
<body>
<button onmouseover="myfunction(innerHTML)">initial</button>
<button onmouseover="myfunction(innerHTML)">infinite</button>
<button onmouseover="myfunction(value)" value="4">number</button>
<p>animation-iteration-count</p>
<script>
function myfunction(myparameter)
{
document.querySelector("p").style.animationIterationCount = myparameter;
}
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
margin-left: 0;
}
100%
{
margin-left: 200px;
}
}
p
{
animation-duration: 4s;
animation-name: mykeyframes;
}
</style>
</head>
<body>
<button>initial</button>
<button>infinite</button>
<button value="4">number</button>
<p>animation-iteration-count</p>
<script>
function myfunction(myparameter)
{
document.querySelector("p").style.animationIterationCount = myparameter;
}
const myelements = document.querySelectorAll("button");
for(let myelement of myelements)
{
let myargument = myelement.innerHTML;
if(myelement.value)
{
myargument = myelement.value;
}
myelement.addEventListener("mouseover", function(){myfunction(myargument)});
}
</script>
</body>
</html>