我目前有一個表,並在1列刪除鏈接,如果用戶點擊這個鏈接它觸發一個onClick基本上標誌該項目將被刪除,並隱藏TR。 它工作正常,但我只是想知道是否有更好的方法.....jquery - 設置值
$(document).on('click', '.deleteCell', function (e) {
//Belt and braces - only do this for <td> elements
var target = $(e.target);
if (!target.is('td')) {return;}
var h = this.innerHTML;
var newH = h.replace("CsUpdated", "CsDeleted");
newH = newH.replace("CsAdded", "CsDeleted");
this.innerHTML = newH;
//We clicked on a TD so get the row TR.
var theRow = $(this).closest('tr');
theRow.hide();
});
我只是想一定比字符串操作,我與替換做一個更好的辦法?在那兒? 我嘗試過這些,但沒有運氣...
$(this).attr('value', 'CsDeleted');
$(target).attr('value', 'CsDeleted');
$(this).val('CsDeleted');
$(target).val('CsDeleted');
感謝
use .text()or .html() – guradio
表格數據單元沒有值。你究竟在做什麼? – Quentin
希望是TD