2016-09-02 4 views
-1

테이블의 셀 (특정 행)을 반복하고 셀 값을 변경하려고합니다. 셀 요소 (td) 또는 행 요소 (tr)에는 클래스 나 ID가 없습니다.테이블을 반복하고 셀 내용을 변경하십시오.

이 내가 할 것입니다 :

$(document.body).on("click", "._cancel_btn",function(e){ 
    $(this).closest('tr').find('td').each (function() { 
    var cellText = $(this).html(); 
    alert(cellText) // gives me the current value in td 
    }); 
행의 TD를 반복하면서

가 어떻게 각 셀의 내용을 대체 할 수 있습니까?

+0

당신이 대체 무엇을 원하는가? – pwolaq

+1

은'$ (this) .text ("hello");와 같습니다. – trincot

답변

0

내가 오순절 갈 것이 :

$(document.body).on("click", "._cancel_btn",function(e){ 
    $(this).closest('tr').find('td').each (function() { 
    var cellText = $(this).html(); 
    alert(cellText) // gives me the current value in td 
    $(this).text("YOUR NEW TEXT"); 
    }); 
}) 
관련 문제