このコードを、アイテム1をクリックすると1つの機能を実行し、アイテム2をクリックすると別の機能を実行するように機能させようとしています。今のところ、それらはすべて同じものに行き、私はそれを引き離すことができないようです。
var list = [];
list[0] = ["zero"];
list[1] = ["one"];
list[2] = ["two"];
list[3] = ["three"];
function Make(){
for ( var i = 0; i < 4 ; i++ ) {
var div = document.createElement("div");
div.style.width = "10px";
div.style.height = "10px";
div.style.background = "white";
div.style.color = "black";
div.style.top = "0px";
div.style.left = "0px";
div.style.margin = "10px 10px auto";
div.style.cursor = "pointer";
div.innerHTML = list[i];
!function(){
var index = 0;
div.onclick = function () { alert("this works"); };
}();
document.body.appendChild(div);
}
}