<span id=变量1>  变量2  </span>   变量2进行倒计时,其中变量1,变量2可能含有多个值,请问谁会写这个js  当只有一个值的时候可能就出现一个  <span id=0>  数值1(为秒)  </span>  ,但是有2个值的时候就出现n个  <span id=0>  数值1(为秒)  </span>  ,  <span id=1>  数值2(为秒)  </span>  ,依次类推 他是谁啊?

解决方案 »

  1.   

    写在一个Element里面
    例:
    <div id='box'>
    <span id="x">5</span>
    ....
    </div><script>
    function time(){
      var b=document.getElementById("box").getElementsByTagName("span")
      for(i=0;i<b.length;i++){
        b[i].innerHTML =-1;
      }
    }
    </script>
    应该这样可以了
      

  2.   


    <script language=javascript>
    var creatIt = function (){
        n= document.getElementById("number").value||3;
       for(var i=0;i<n;i++){
        var a = document.createElement('span');
        a.innerHTML = '100';
        a.id =i;
        document.body.appendChild(a);
        var b = document.createElement('input');
        b.target = a;
        b.type='button';
        b.value='start';
        b.onclick = start;
        document.body.appendChild(b);
       }
    }
    function start(o){
       o=o||this.target
       o.innerHTML -= 1;
       if(o.innerHTML>0)setTimeout(function(){start.call(window,o);},1000);
    }
    </script>
    <input id="number" type="text" value= 5></input>
    <input type="button" value="creat" onclick="creatIt()"/>
      

  3.   

    var reurl = "";
    var retime = 60;
    var remethod = "_self";
    function autoreturn(argurl,argtime,argmethod) { 
    var speed = 1000;
    var argc = autoreturn.arguments.length;
    reurl=argc>=1&&argurl!=""?argurl:reurl;
    retime=argc>=2&&argtime>0?argtime:retime;
    remethod=argc>=3&&argmethod!=""?argmethod:remethod;
    autoreturnstr="\
    系统将于\
    <font color=red>\
    <div id='timeflag' style='display:inline'>"+retime+" </div></font>\
    秒之后 <a id=return href="+reurl+">返回</a>\
    ";
    if(retime==0){
    location.href=reurl; 
    clearTimeout(autotime);
    return;
    }
            if(typeof(autolabel)=="undefined")document.write("<div id=autolabel></div>");
    if(typeof(timeflag)=="undefined")document.getElementById("autolabel").innerHTML=autoreturnstr;
    else document.getElementById("timeflag").innerHTML=retime+" ";
    if (retime>0){
    retime--;
    //alert(eval("autoreturn()"))
    autotime=window.setTimeout("autoreturn()", speed);
    document.getElementById("return").focus(); 
    }
    }
    贴个单个的,进行改造即可。
      

  4.   

    <script type="text/javascript">
        //获取时间
        window.onload=GetServerTime(15*60*1000);
    function Timer(span)
    {
    var tmp = new Date();
    var milsecs=Date.parse(tmp.getMonth()+"-"+tmp.getDay()+"-"+tmp.getFullYear()+" "+document.getElementById('lbl_Hour').innerText+":"+document.getElementById('lbl_Minute').innerText+":"+document.getElementById('lbl_Second').innerText); var timer = new Date(milsecs+span);
    var seconds,minutes,hours,date;
    if(timer.getSeconds()<10)
    seconds = "0"+timer.getSeconds();
    else
    seconds = timer.getSeconds();
    if(timer.getMinutes()<10)
    minutes = "0"+timer.getMinutes();
    else
    minutes = timer.getMinutes();
    if(timer.getHours()<10)
    hours = "0"+timer.getHours();
    else
    hours = timer.getHours();
    date=timer.getDate();
    document.getElementById('lbl_Second').innerText = seconds;
    document.getElementById('lbl_Minute').innerText = minutes;
    document.getElementById('lbl_Hour').innerText = hours;
    }

    //得到服务器时间每隔updatespan分钟校验一次,每秒更新一次本地时钟
    function GetServerTime(updatespan)
    {

    var clientspan = 1*1000;
    //更新本地时钟

    setInterval("Timer("+clientspan+")",clientspan);
    //同步服务器时钟

    setInterval("window.location.href='JoinExamList.aspx'",updatespan);
    }
        </script>
      

  5.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>title</title>
    <style type="text/css">
    div { margin: 5px; padding: 3px; border: 1px solid green; background-color: #ccc; }
    div span { font-size: 12px; color: black; }
    </style>
    </head>
    <body>
    <div id="div0"></div>
    <div id="div1"></div>
    <div id="div2"></div>
    <div id="div3"></div>
    <script type="text/javascript">
    <!--
    function t2s(t) {
    var s = t.replace(/(\d+):(\d+):(\d+)/, function ($0, $1, $2, $3) {
    return parseInt($1) * 3600 + parseInt($2) * 60 + parseInt($3)
    });
    return isNaN(s) ? 0 : s;
    }
    function s2t(n) {
    var s, m, h;
    if (isNaN(n) || n < 0)
    return "";
    s = n % 60;
    n = (n - s) / 60;
    m = n % 60;
    h = (n - m) / 60;
    return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
    }
    function Timer(container, id, time, func) {
    var span = document.createElement("span");
    container = container || document.body;
    container.appendChild(span);
    span.id  = id;
    span.time = t2s(time);
    span.innerText = time;
    Timer.reg(span, func);
    }
    Timer.id = null;
    Timer.list = [];
    Timer.reg = function (item, func) {
    Timer.list[Timer.list.length] = {"item": item, "func": func};
    if (null == Timer.id)
    Timer.id = window.setTimeout(Timer.func, 1000);
    }
    Timer.func = function () {
    var i, n, o;
    if (Timer.list.length > 0) {
    Timer.id = window.setTimeout(Timer.func, 1000);
    for (i = Timer.list.length - 1; i >= 0; i--) {
    o = Timer.list[i];
    o.item.innerText = s2t(--o.item.time);

    if (o.item.time == 0) {
    Timer.list.splice(i, 1);
    if (o.func)
    o.func.call(o.item);
    }
    }
    }
    if (Timer.list.length == 0) {
    window.clearTimeout(Timer.id);
    Timer.id = null;
    }
    }
    var ids = [1, 2, 3, 4];
    var times = ["01:02:03", "00:00:20", "00:00:10", "00:00:05"];
    var func = function () {
    this.innerText = "time out";
    };
    for (var i = 0; i < ids.length; i++)
    Timer(document.getElementById("div" + i), ids[i], times[i], func);
    //-->
    </script>
    </body>
    </html>
      

  6.   

    星辰技术社区:www.netcsharp.cn,我们将帮您以最快的速度找到最佳的解决方案 
      

  7.   

    灌水机代码:www.dullwolf.cn/CSDNer.rar下载。