/// <reference path="..\jquery-1.4.1-vsdoc.js"/>
$(function () {
var div = $("#content");
change_div("content", 50, 50, 50, "blue");
div.before($("<button>").html("move").attr("id", "move"));
$("#move").click(function () { move_div(); });
// $(document).append(div)//
//$(document).append(create_div("", 10, 10, 100, "b", "green"));
})
function move_div() {
var a = ["250", "100", "150", "200", "250"];
//alert(a[2]);
//change_div("content", 50, 50, 150, "blue");
//setTimeout(function () { change_div("content", 50, 50, 150, "blue"); }, 1000);
for (var i = 0; i < a.length; i++) {
//document.write(a[i]);
//setTimeout(function () { change_div("content", 50, 50, a[i], "blue"); }, a[i] * 2);
setTimeout(function () { $("#content").css("left", a[i]); }, i*1000);
}
}
function change_div(oid, width, height, left, backgroundcolor) {
var a = $("#" + oid + "");
//a.addClass("pan");
//a.html(content);
a.css("width", width);
a.css("position", "absolute");
a.css("left", left);
a.css("height", height);
a.css("background-color", backgroundcolor);
//a.attr("id", id);
return a;
}
1 var i = 0;
2 var intervalProcess;
3
4 $(function () {
5 var div = change_div("content", 50, 50, 50, "blue");
6
7 div.before($("<button>").html("move").attr("id", "move"));
8
9 $("#move").click(function () { intervalProcess = setInterval(move_div, 1000); });
10
11 })
12
13
14 function move_div() {
15 var a = [250, 100, 150, 200, 250];
16 $("#content").css("left", a[i]);
17 i++;
18 if (i > a.length) {
19 clearInterval(intervalProcess);
20 i = 0;
21 return false;
22
23 }
24 }
25
26 function change_div(oid, width, height, left, backgroundcolor) {
27 var a = $("#" + oid + "");
28 a.css("width", width);
29 a.css("position", "absolute");
30 a.css("left", left);
31 a.css("height", height);
32 a.css("background-color", backgroundcolor);
33 return a;
34 }
gif图片能动