js 动画效果代码,主要运用setTimeout
2011-09-20 17:14
309 查看
代码只能对以px为单位的样式进行改变。
js Code:
html Code:
js Code:
function animate(ele,name,from,to,time) { time = time ||800; var interval,count,step,now; interval = 60; count =Math.round(time/interval); step = Math.round((to-from)/count); now = from; var style = document.getElementById(ele).style; function go() { count--; now = count?now+step:to; style[name] = now + "px"; if(count) { setTimeout(go,interval); } } style[name] = from + 'px'; setTimeout(go,interval); }
html Code:
<p > <span id ='s1'>goole!!!!!goole</span> </p> <input type="button" value="changeSize" onclick="animate('s1','font-size',9,50,1000)">
相关文章推荐
- js 动画效果代码,主要运用setTimeout
- js实现div拖动动画运行轨迹效果代码分享
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- 仿谷歌主页js动画效果实现代码
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- jquery的animate动画效果函数用JS代码是如何实现的
- 在iframe里的页面编写js,实现在父窗口上创建动画效果展开和收缩的div(不变动iframe父窗口代码)
- js实现div拖动动画运行轨迹效果代码分享
- JS实现响应鼠标点击动画渐变弹出层效果代码
- js实现的动画导航菜单效果代码
- js动画效果制件让图片组成动画代码分享
- JS弹窗效果的运用(代码)
- JS动画效果代码2
- 在iframe里的页面编写js,实现在父窗口上创建动画效果展开和收缩的div(不变动iframe父窗口代码)
- 实现动画效果核心方式的js代码
- JS实现网页右侧带动画效果的伸缩窗口代码
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- JS打开层/关闭层/移动层动画效果的实例代码
- JS动画效果代码3