window.tx = []; function setText(id)
{
var txt=new Array();
txt[0]=id;
Time(txt);
}

解决方案 »

  1.   

    其实不用传什么数组,加个参数判断下就好了function setText(id)
    {
    var txt=new Array();
    txt[0]=id;
    Time(txt,1);
    }
    function setRect(id)
    {
    var rect=new Array();
    rect[0]=id;
    Time(rect,2);
    }
    function Time(var1,t)
    {
    var tDate = new Date();
    var tseconds = tDate.getSeconds();
    var timeStr = '当前时间是' + tDate.getHours() + ':' + tDate.getMinutes() + ':' + tseconds;
    if(t==2)
    {
    var a=document.getElementById(var1[0]);
    a.setAttribute("height",tseconds);
    }
    if(t==1)
    {
    var b=document.getElementById(var1[0]);
    b.textContent=timeStr;
    }
    }