Ajax 호출에서 작성중인 테이블 행이 있습니다. 나는 onlclick 이벤트를 연관시키고 싶다. 제가 는 그래서 클릭 이벤트의 배열 요소를 잡을 수없는이다테이블 행의 onclick 이벤트에 값을 전달하십시오.
var d = $.parseJSON(data.codes);
for (var i = 0; i < d.length; i++) {
var currentRow = $('<tr>');
currentRow.append($('<td>').html(d[i].id));
currentRow.attr("class", "sourceCodeRow grid-row");
currentRow.append($('<td>').html(d[i].name));
currentRow.append($('<td>').html(d[i].description));
currentRow.click(function (f) {
//want to display name from d[i]
// alert(d[i].name);
});
$('#table-id').append(currentRow);
}
이 유 내 코드 좋은 – Madbreaks
를 수정하십시오 $ (이)를 사용할 필요가 있다고 생각합니다. 그것은 일했다! 덕분에 –