<mce:script type="text/javascript" src="../jquery-1.2.3-intellisense.js" mce_src="jquery-1.2.3-intellisense.js"></mce:script>
<mce:script type="text/javascript"><!--
$(function() {
dayuan(200, 500, 200, 270, -90);
setTimeout(" dayuan(50, 420, 150, 180, 0);", 5000);
setTimeout(" dayuan(50, 590, 150, 180, 0);", 9000);
setTimeout(" dayuan(50, 500, 250, 0, -180);", 13000);
}
)
function dayuan(r,x,y,a,c) { //r 圆半径,x 圆心的横坐标,a 起始角度,y 圆心纵坐标,c 终点坐标
var div = document.getElementById("div1");
var xs = setInterval(function test() {
var b = (Math.PI * (a)) / 180; //角度换成弧度
a = a - 1; //每一次按一度递减
div.style.top = eval(y - r * Math.sin(b)) + "px"; //设置新的坐标
div.style.left = eval(x + r * Math.cos(b)) + "px";
var off = $("#div1").offset(); //获取新的坐标
$("body").append("<div id='div" + off.left + off.top + "' class=\"te\"></div>"); //添加圆的每一个点
var divx = document.getElementById("div" + off.left + off.top);
divx.style.left = off.left+"px"; //设置圆的每一个点的坐标
divx.style.top = off.top+"px";
// alert($("#div" + off.left + off.top).offset().left+" "+off.left);
if (a == c) {
clearInterval(xs);
}
}, 10);
}
// --></mce:script>
#div1
{
width:5px;
height:5px;
background-color:Black;
position:absolute;
top:100px;
left:50px;
overflow:hidden;
}
.te
{
position:absolute;
width:5px;
height:5px;
background-color:#ff0000;
overflow:hidden;
}
html代码
<div id="div1"></div>