HTML 셀의 데이터에 액세스해야하지만 그 전에는 셀에 내 배열 ID (details [i] .id)를 저장해야합니다. 나는 숨겨진 것으로 시도했지만 테이블을 보여줄 때 빈 셀을 얻었고 원하는 것은 아니었고 원하는 것은 ASP.net의 DataKeyNames와 같았습니다.이 태그는 ID를 반드시 표시하지 않고 저장할 수있는 기회를줍니다. . ,HTML 테이블 셀 데이터에 액세스
function showTable()
{
if (details.length>0){
for (var i=0; i<details.length;i++)
{
var tbl = document.getElementById('myTable');
var newRow = tbl.insertRow(tbl.rows.length);
var cell1 = newRow.insertCell(0);
cell1.textAlign='center';
cell1.innerHTML=details[i].price;
var cell2 = newRow.insertCell(1);
cell2.textAlign='center';
cell2.innerHTML=details[i].description;
var cell3 = newRow.insertCell(2);
cell3.textAlign='center';
cell3.innerHTML='<a href="#"><img src="images/delete.png" width="14" height="14" alt="Delete" onclick="removeDetail(this)"/></a>'
}
}
}
내가 셀 값을 얻을 필요가 어디에 마지막으로 removeDetail 기능에 어떻게 든 가정 :
이
내가 HTML 테이블에 내 배열 (세부 사항)을 표시하는 데 사용하는 코드입니다 이드를 거기에 넣어 라.function removeDetail(r)
{
var node = r.parentNode;
while(node && node.tagName !== 'TR') {
node = node.parentNode;
}
var i=node.rowIndex;
document.getElementById('myTable').deleteRow(i);
//here's where I need to get the id and, if posible the other values (price, description) too.
}
희망을 보내주세요.
하십시오! 어떤 아이디어? : ( – eddy
댓글은 당신의 질문에 부딪치지 않을 것입니다, 당신은 그것을 다시 상단으로 부딪 치기 위해 편집 할 수 있지만 그렇게 빨리하지 마십시오. 부딪 치기 전에 반나절 이상 기다리십시오. –