<!DOCTYPE?html>
<html?lang="en">
<head>
????<meta?charset="UTF-8">
????<title>Document</title>
????<style?type="text/css">
????????*?{
????????????padding:0px;?margin:0px;?font-size:111px;
????????}
????????#div1?{
????????????margin:350px?0?0?;?
????????}
????</style>
????<script?type="text/javascript">
????????function?toDou(n){
????????????if(n>10){
????????????????return?""+n;
????????????}else{
????????????????return?"0"+n;???
????????????}
????????}
????????window.onload=function?()?{
?????????//這是以第一個版本?。。。。。。?!
????????????setInterval(function(){
????????????????var?oImg=document.getElementsByTagName("img");
????????????var?oDate=new?Date();
????????????var?str=toDou(oDate.getHours())+toDou(oDate.getMinutes())+toDou(oDate.getSeconds());
????????????????for(var?i=0;i<oImg.length;i++){
????????????????????oImg[i].src=str.charAt(i)+'.png';
????????????}???????
????????????},1000);
????????//這是第二個版本!?。。。。。。?!
????????/*??????function?haha(){
????????????????var?oImg=document.getElementsByTagName("img");
????????????????var?oDate=new?Date();
????????????????var?str=toDou(oDate.getHours())+toDou(oDate.getMinutes())+toDou(oDate.getSeconds());
????????????????for(var?i=0;i<oImg.length;i++){
????????????????????oImg[i].src=str.charAt(i)+'.png';
????????????}???????
????????}
????????????????setInterval(haha(),1000);*/
????</script>
</head>
<body>
????<div?id="div1">
????????<img?src="1.png">
????????<img?src="1.png">
????????:
????????<img?src="1.png">
????????<img?src="1.png">
????????:
????????<img?src="1.png">
????????<img?src="1.png">
????</div>
</body>
</html>請問為什么第一個版本可以正常運行,而第二個版本我只是給fucntion() 加了個名字,然后在setInterval中調用它就不成功了呢?!!
求教關于setInterval
超級巨浪大切
2017-11-29 22:47:55