我在使用附加的锚点附加 onclick 事件时遇到问题。当我单击一行时,它没有给我迭代 id。
for (var i = 0; i <= oRes.projects.length; i++) {
jQuery('<a/>', {
href: "#_",
html: oRes.projects[i]['project_name'] + "<span>" + oRes.projects[i]['project_duration'] + "</span>" + i,
class: "setup-button projectItems",
"data-role": "button",
"data-iconpos": "left",
"data-projectId": oRes.projects[i]['project_id'],
"click": function() {
alert(i);
}
}).appendTo('#myprojectList');
$('#myprojectList a').button();
}