jquery实现动态画圆
今天自己在写插件过程做中找到的一个不错的知识。自己做了一个小例子。
<!doctypehtml>
<html>
<head>
<metacharset="utf-8">
<title>无标题文档</title>
<!--脚本加载-->
<scriptsrc="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"type="text/javascript"></script>
<scripttype="text/javascript">
$(document).ready(function(e){
vara=200,b=200,r=90,times=0;
setInterval(functionflutter(){
times+=0.1;
varhudu=(2*Math.PI/360)*6*times;
varX=a+Math.sin(hudu)*r;
varY=b-Math.cos(hudu)*r // 注意此处是“-”号,因为我们要得到的Y是相对于(0,0)而言的。
//$(".sky_text").css({"left":X+"px","top":Y+"px"});
$("body").append('<divstyle="position:absolute;left:'+X+'px;top:'+Y+'px;width:1px;height:1px;background:#00F;"></div>');
if(times==60){
return;
}
},2);
});
</script>
<styletype="text/css">
body,html{padding:0;margin:0;}
</style>
</head>
<body>
<divstyle="position:absolute;left:198px;top:198px;width:4px;height:4px;background:#F00;"></div>
</body>
</html>