ループによって生成された各 div にユーザー名の ID を割り当てました。これで問題ありません。各 div/button には、ID としてユーザー名があります。ただし、ここの例を使用して、別のページに div のコンテンツをロードし、他の投稿で、その div とそのコンテンツを別のページに送信し、名前の値も渡そうとしています。アラートは名前を警告していますが、私の試みは機能していません。値を正しく渡していますか? 次のページで div を再作成するにはどうすればよいですか? 最後に、最終的には人にテーブルを付けたいので、これも正しいアプローチですか。十分に長い間?
identity = results.rows.item(i).username;
userDiv.id = identity;
console.log(identity);
(function (identity) {
userDiv.addEventListener("click",
function () {
window.open("whatever.html");
$('#singleUser').load('index.html #userDiv');
//var singleUser = document.getElementById("singleUser");
//singleUser.appendChild(userDiv);
alert(identity);
console.log(identity);
}, false);
})(identity);