您现在的位置:首页 >> 分类信息 >> 其他信息 >> 内容

js文字循环显示逐渐放大缩小

时间:2026/8/26 11:32:12 点击:

  核心提示:html head meta http-equiv=content-type content='text/html;charset=GBK' script var students = ['A', '...

<html>
<head> 
<meta http-equiv=content-type content="text/html;charset=GBK"> 


<script>   var students = ["A", "B", "C", "D", "E", "F",  "G",  "S", "T", "U", "V", "W", "X","Y", "Z"];                      // 做了一个自定义的堆栈,来实现顺序显示 
   
var stack = {tags : [document.createElement("h5"),
      document.createElement("h4"),     
   document.createElement("h3"),     
   document.createElement("h2"),     
   document.createElement("h1"),     
   document.createElement("h2"),     
   document.createElement("h3"),     
   document.createElement("h4"),     
   document.createElement("h5")],   
   data : ["", "", "", "", "", "", "", "", ""],   
   push : function(text){    
   this.data.shift();   
    this.data.push(text);         
    for(var i=0; i<this.tags.length; i++){     
    this.tags[i].innerHTML = this.data[i];
    }    }   };  </script>
       </head>
       <body> </body>
   
<script> 
 var tags = stack.tags; 
  for(var j=0; j<tags.length; j++)   document.body.appendChild(tags[j]);     // 每一秒显示一个姓名
     
function func(){  
var index = 0;  
var len = students.length;     
var timer = setInterval(function(){  
if(index<len) { stack.push(students[index]); index=index+1;} else { index=1;stack.push(students[index-1]);} }, 1000);  }
func(); </script>

<script> 
// var tags = stack.tags; 
//  for(var j=0; j<tags.length; j++)   document.body.appendChild(tags[j]);     // 每一秒显示一个姓名
//     
//function func(){  
//var index = 0;  
////var len = students.length*2;     
//var timer = setInterval(function(){    var text = students[index++];// 如果达到最后一个姓名,则停止循环       
////if(text) { stack.push(text); }    else { clearInterval(timer); return false; }       }, 100);  } 
//if(text) { stack.push(text); }    else { var text1 = students[index--];} }, 100);  }
//func(); </script>

</html>

作者:不详 来源:网络
共有评论 0 条相关评论
发表我的评论
  • 大名:
  • 内容:
  • 123笑话大全-短信大全-成人笑话-成人短信(www.ji-su.com.cn) © 2026 版权所有 All Rights Reserved.
  • www.ji-su.com.cn 冀ICP备05011918号
  • Powered by V3.0