<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
*{
margin:0px;
padding:0px;
}
#move {
background-color: #06C;
height: 100px;
width: 100px;
position: absolute;
left:0px;
}
-->
</style>
</head><body>
<div id="move"></div>
<script type="text/javascript">
function $(elem)
{
return document.getElementById(elem);
}
var asd=$("move");
var change=400;
var begin=0;
var time=0;
var dur=10000;
var t=setInterval("tween(time,change,dur,begin)",1000);
function quad(time,change,dur,begin)
{
return Math.pow(time/dur,2)*change+begin;
}
function tween(time,change,dur,begin)
{
asd.style.left=quad(time,change,dur,begin)+"px";
time+=1000;
if(time>=dur)
{
clearTimeout(t);
}
}
</script>
</body>
</html>
到底是哪里有问题呢,搞了好久没发现问题,就是不动。求指点啊啊啊
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
*{
margin:0px;
padding:0px;
}
#move {
background-color: #06C;
height: 100px;
width: 100px;
position: absolute;
left:0px;
}
-->
</style>
</head><body>
<div id="move"></div>
<script type="text/javascript">
function $(elem)
{
return document.getElementById(elem);
}
var asd=$("move");
var change=400;
var begin=0;
var time=0;
var dur=10000;
var t=setInterval("tween(time,change,dur,begin)",1000);
function quad(time,change,dur,begin)
{
return Math.pow(time/dur,2)*change+begin;
}
function tween(time,change,dur,begin)
{
asd.style.left=quad(time,change,dur,begin)+"px";
time+=1000;
if(time>=dur)
{
clearTimeout(t);
}
}
</script>
</body>
</html>
到底是哪里有问题呢,搞了好久没发现问题,就是不动。求指点啊啊啊
解决方案 »
- 这两个格式的JSON在解析上是不一样的是吗?
- jquery的一个fadeout效果的具体使用方法,立马结贴!
- js 无法给 a href赋值,帮我找找问题吧
- jquery中dialog的问题
- 服务器端与客户端数据同步问题
- 如何控制input的背景色?
- 请问网页上面的flash老是挡住javascript菜单
- 我想用客户端JavaScript删除internet缓存中的一个cookies文件
- 求解,在javascript中是否存在全局变量和局部变量的问题;
- 想问一下关于爬取Jsonp数据格式的问题
- Google Maps API里的GDirections 如何使用?
- window.open("","_self"); 这句什么意思?
<div id="move"></div>
<script type="text/javascript">
function $(elem) {
return document.getElementById(elem);
}
var asd=$("move");
var change=400;
var begin=0;
var time=0;
var dur=10000;
var t=setInterval("tween()",1000);
function quad() {
return Math.pow(time/dur,2) * change + begin;
}
function tween() {
asd.style.left=quad()+"px";
time += 1000;
if(time>=dur) {
clearTimeout(t);
}
}
</script>
</body>