//======================================================================== //id:对象id //butid:按钮id //dir:1为水平方式,2为上下方式 //fnum:最终目标值 //mouse:鼠标事件 //sp:速度 var tt; function Unfold(id,butid,dir,fnum,mouse,sp){ $(butid)[mouse]=function(){clearInterval(tt);tt=setInterval(mov,5);} //鼠标事件执行效果 function mov(){ var idwh=(dir==1)?parseInt($(id).offsetWidth):parseInt($(id).offsetHeight); //得到容器的宽或高 var v=(fnum<idwh)?Math.floor((fnum-idwh)/sp):Math.ceil((fnum-idwh)/sp); //算出每次运动量 (dir==1)?$(id).style.width=idwh+v+"px":$(id).style.height=idwh+v+"px"; if (v==0){clearInterval(tt);} $("abc").innerHTML=idwh+"<br>"; } } </script> </head>