如题,js差,求助

解决方案 »

  1.   

    <div id="divTime" onmouseover="ir=window.clearInterval(ir);" onmouseout="ir=setInterval("setTime()",1000);"></div>
    -----------------
    JS:
    function setTime()
    {
    var div=document.getElementById('divTime');
    div.innerHTML=new Date().getTime();
    }
    var ir=setInterval("setTime()",1000);
      

  2.   

    <!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>Untitled Page</title>
    </head>
    <body>
        <div id="divTime" onmouseover="ir=window.clearInterval(ir);" onmouseout="ir=setInterval('setTime()',1000);"> </div> 
        <script type="text/javascript">
            function setTime() 
            { 
            var div=document.getElementById('divTime'); 
            div.innerHTML=new Date().getHours()+"-"+new Date().getMinutes()+"-"+new Date().getSeconds(); 
            } 
            var ir=setInterval("setTime()",1000);     </script>
    </body>
    </html>
      

  3.   

    <html> 
    <head> 
    <meta   http-equiv= "Content-Type "   content= "text/html;   charset=UTF-8 "> 
    <script>
    var timer = 0;
    window.onload=function(){
      timer = setInterval("abc()",1000)
    }
    function abc(){
      var a = document.getElementById("demo");
      var time = parseInt(a.innerHTML);
      a.innerHTML = time-1;
    }function bcd(){
      clearInterval(timer);
    }
    function efg(){
      timer = setInterval("abc()",1)
    }
    </script>
    </head> 
    <body>
    <div  id="demo" onmouseover="bcd()" onmouseout="efg()" style="border:1px solid black"> 
    1000
    </div> 
    </body> 
    </html>