jquey的setInterval让元素动起来,代码很简单,如下
-
<!DOCTYPE html >
-
<html>
-
<head>
-
<title>playing with the DOM</title>
-
<script src=""></script>
-
</head>
-
<body>
-
<h1 id="heading">Hello world</h1>
-
<script>
-
var leftOffset = 0;
-
var moveHeading = function(){
-
$("#heading").offset({left:leftOffset});
-
leftOffset++;
-
if(leftOffset > 200){
-
leftOffset=0;
-
}
-
}
-
setInterval(moveHeading,30);
-
</script>
-
</body>
-
</html>
阅读(720) | 评论(0) | 转发(0) |