以下のコードを見てください。唯一の変更のカップルとそのちょうどあなたのコード:https://jsfiddle.net/xcmvzpuk/5/
$('.edit').click(function() {
var editId = $(this).attr('id'); //here we will get id like edit0 and edit1 and so on
$("#" + editId).hide();
var number = editId.replace("edit", ""); //grab the number from id
$("#update" + number).show();//show the corresponding update button
var currentTD = $(this).parents('tr').find('td');
//enable the current row
$.each(currentTD, function() {
$(this).prop('contenteditable', true)
});
});
$('.update').click(function() {
var updateId = $(this).attr('id');
$("#" + updateId).hide();
var number = updateId.replace("update", "");
$("#edit" + number).show();
var currentTD = $(this).parents('tr').find('td');
//disable the current row
$.each(currentTD, function() {
$(this).prop('contenteditable', false)
});
});
あなたが達成しようとしていることは、if($(this).html()== 'Edit'){'? – vijayP
あなたの他の部分はcozのみを呼び出すことはありませんeditボタンはclass edit .. ボタン ''を指定するとうまくいきます。あなたのクリックイベントは更新ボタンを呼び出さないので、あなたはそれを変更する必要があります。 – bharat