jsアニメーション

2162 ワード

js                   js       
js

/// <reference path="..\jquery-1.4.1-vsdoc.js"/>
var i = 0;
function move_div() {
var a = [50, 100, 150, 200, 250];
$("#content").css("left", a[i]);
i++;
if (i > a.length) {
clearInterval(intervalProcess);
i = 0;
return false;
}
}

function change_div(oid, width, height, left, backgroundcolor) {
var a = $("#" + oid + "");
a.css("width", width);
a.css("position", "absolute");
a.css("left", left);
a.css("height", height);
a.css("background-color", backgroundcolor);
return a;
}

$(function () {
var div = $("#content");
change_div("content", 50, 50, 50, "blue");
div.before($("<button>").html("move").attr("id", "move"));
$("#move").click(function () { intervalProcess = setInterval(move_div, 1000); });
})