"편집/저장"및 "삭제"단추가 모두 포함 된 테이블이 있습니다. '수정'버튼을 클릭 할 때마다 행을 수정 가능하게 만들고 변경 사항을 저장할 수 있도록 '저장'버튼으로 변경합니다. 그러나 이렇게하면 모든 셀을 편집 할 수있게되고 첫 번째 행에서만 편집 버튼이 작동합니다. 그것은 Button 및 ContentEditable 함수
- 가 어떻게 편집하고 다른 편집 할 수 없습니다 행의 특정 세포를 만들 수 있습니다 ...
내 질문은 두 개의 파트너 사 등등, 두 번째 행, 세 번째 행에 대해 작동하지 않는 이유는 무엇입니까? 첫 번째 셀 "MR_ID"를 편집 할 수 없도록하고 싶습니다.
첫 번째 행 대신 여러 행에서 편집 기능을 사용하려면 어떻게해야합니까?
관련 HTML/PHP 코드 :
<?php
foreach ($dbh->query($sql) as $rows){
?>
<tr>
<td id="mr_id" contenteditable="false"><?php echo intval ($rows['MR_ID'])?></td>
<td id="mr_name" contenteditable="false"><?php echo $rows['MR_Name']?></td>
<td id="buyer_id" contenteditable="false"><?php echo $rows['Buyer_ID']?></td>
<td id="poc_n" contenteditable="false"><?php echo $rows['MR_POC_N']?></td>
<td id="poc_e" contenteditable="false"><?php echo $rows['MR_POC_E']?></td>
<td id="poc_p" contenteditable="false"><?php echo $rows['MR_POC_P']?></td>
<td><button id="edit" name="edit">Edit</button>
<button id="delRow" name="delete" onclick="deleteRow(this)">Delete</button></td>
</tr>
관련 자바 스크립트 코드 :
$(document).ready(function() {
$('#edit').click(function() {
var $this = $(this);
var tds = $this.closest('tr').find('td').filter(function() {
return $(this).find('#edit').length === 0;
});
if ($this.html() === 'Edit') {
$this.html('Save');
tds.prop('contenteditable', true);
} else {
$this.html('Edit');
tds.prop('contenteditable', false);
}
});
});
당신이 deleteRow를 수행 한 (this), editRow (this)를하지 않은 이유가 무엇입니까? – Keith