Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <p>animationiteration counter</p>
  <div id="target"></div>
  <div id="log"></div>
</body>
</html>
 
#target {
  width: 100px;
  height: 100px;
  background: green;
  animation: 1s spin infinite;
}
@keyframes spin {
  0% { transform: rotateZ(0);}
  100% { transform: rotateZ(360deg);}
}
#log {
  white-space: pre;
}
 
document.getElementById('target').addEventListener('animationiteration', iteration);
let iterations = 0;
function iteration() {
  ++iterations;
  let seconds = Math.round(performance.now() / 1000);
  document.getElementById('log').textContent = `${iterations} iterations after ${seconds} seconds`
}
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
flackrpro
0viewers