JS_定时器setTimeout 笔记
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>定时器setTimeout</title>
<script type="text/javascript">
function cl(){
var img1=document.getElementsByTagName('img')[0];
if (img1.src.indexOf('1.jpg')>=0) {
img1.src='2.jpg';
} else{
img1.src='1.jpg';
}
}
window.setTimeout('cl()', 2000);
</script>
</head>
<body>
<h1>定时器使用</h1>
<img src="1.jpg" alt="" />
</body>
</html>
Dcr163的博客
http://dcr163.cn/55.html(转载时请注明本文出处及文章链接)