我想在 x 秒后停止我的 javascript,我看到函数是 setTimeout,我试图将它添加到我的代码中但没有成功,这是更好的方法吗?谢谢你的帮助 !
<html>
<head>
<script type="text/javascript">
function blink(){
state = document.getElementsByTagName('img')[0].style.visibility;
if(state == 'hidden'){
newState = 'visible';
}else if(state == 'visible'){
newState = 'hidden';
}
document.getElementsByTagName('img')[0].style.visibility = newState;
}
setInterval('blink();', 300);
</script>
</head>
<body>
<img src="http://ww1.prweb.com/prfiles/2011/10/12/8875514/star_white.jpg" style="visibility:hidden">
</body>
</html>