所以我现在有一个表格,我可以按下按钮并“停用”一行。通过停用该行,发生的所有情况都是不透明度更改,并且该行显示为灰色,表示行已“停用”。 “取消激活”按钮也会更改为“激活”。我想要的是能够点击“激活”按钮,并能够将该行解除灰色,然后该按钮将变回“停用”。每次点击一个按钮时的多种功能
下面是我的一些代码...
HTML/PHP:
<tr>
<td class="mr_id" contenteditable="false"><?php echo intval ($rows['MR_ID'])?></td>
<td class="mr_name" contenteditable="false"><?php echo $rows['MR_Name']?></td>
<td class="buyer_id" contenteditable="false"><?php echo $rows['Buyer_ID']?></td>
<td class="poc_n" contenteditable="false"><?php echo $rows['MR_POC_N']?></td>
<td class="poc_e" contenteditable="false"><?php echo $rows['MR_POC_E']?></td>
<td class="poc_p" contenteditable="false"><?php echo $rows['MR_POC_P']?></td>
<td><button class="edit" name="edit">Edit</button>
<button class="deactivate" name="deactivate">Deactivate</button></td>
</tr>
的JavaScript:
// ----- Deactivate Row -----
$(document).ready(function() {
$('.deactivate').click(function() {
var $this = $(this);
if ($this.html() === 'Deactivate') {
$this.html('Activate');
var result = confirm("Are you sure you want to deactivate this entry?");
if(result) {
$this.closest('tr').css('opacity', 0.5);
}
}
});
});
我很惊讶....只是做与你做的相反。使用翻盖,就像一个属性值来确定采取哪种动作 –