JavaScript 红灯笼闪烁效果代码示例 - 3 秒循环
<html>
<head>
<title>Red Lantern Blinking</title>
<script>
function blink() {
var lantern = document.getElementById('lantern');
if (lantern.style.visibility == 'visible') {
lantern.style.visibility = 'hidden';
} else {
lantern.style.visibility = 'visible';
}
}
setInterval(blink, 1000); // Blink every second
setTimeout(function() { clearInterval(); }, 3000); // Stop blinking after 3 seconds
</script>
</head>
<body>
<div id='lantern' style='background-color:red; width:100px; height:100px;'></div>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/mmx1 著作权归作者所有。请勿转载和采集!