Javascript 使列不可编辑,同时使其他列保持可编辑状态
我有一个多栏多行的表格,还有一个编辑按钮。我想使两列,MR_ID和MR_Name,不可编辑,同时在单击编辑按钮后保持其余列可编辑。我想远离Javascript 使列不可编辑,同时使其他列保持可编辑状态,javascript,php,jquery,html,contenteditable,Javascript,Php,Jquery,Html,Contenteditable,我有一个多栏多行的表格,还有一个编辑按钮。我想使两列,MR_ID和MR_Name,不可编辑,同时在单击编辑按钮后保持其余列可编辑。我想远离.not(),因为它会对我的更新功能产生负面影响。我还有什么其他方法可以做到这一点 表格的HTML/PHP: <table id="html_master" class="ui-widget ui-widget-content"> <thead> <tr class="ui-widget-header"> &
.not()
,因为它会对我的更新功能产生负面影响。我还有什么其他方法可以做到这一点
表格的HTML/PHP:
<table id="html_master" class="ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header">
<td>ID</td>
<td>Vendor</td>
<td>Buyer ID</td>
<td>POC Name</td>
<td>POC Email</td>
<td>POC Phone</td>
<td>Edit</td>
</tr>
</thead>
<tbody>
<?php
/* Foreach loop that brings in information to populate table */
foreach ($dbh->query($sql) as $rows){
?>
<tr id="<?php echo intval ($rows['MR_ID'])?>">
<td class="mr_id" id="mr_id-<?php echo intval ($rows['MR_ID'])?>" contenteditable="false"><?php echo intval ($rows['MR_ID'])?></td>
<td class="mr_name" id="mr_name-<?php echo intval ($rows['MR_ID'])?>" name="field" contenteditable="false"><?php echo $rows['MR_Name']?></td>
<td class="buyer_id" id="buy_id<?php echo intval ($rows['MR_ID'])?>" contenteditable="false"><?php echo $rows['Buyer_ID']?></td>
<td class="poc_n" id="poc_n-<?php echo intval ($rows['MR_ID'])?>" contenteditable="false"><?php echo $rows['MR_POC_N']?></td>
<td class="poc_e" id="poc_e-<?php echo intval ($rows['MR_ID'])?>" contenteditable="false"><?php echo $rows['MR_POC_E']?></td>
<td class="poc_p" id="poc_p-<?php echo intval ($rows['MR_ID'])?>" contenteditable="false"><?php echo $rows['MR_POC_P']?></td>
<td><input type="button" class="edit" name="edit" value="Edit">
</tr>
<?php
}
?>
</tbody>
</table>
您可以创建这个css类,并使用jquery将其添加到正确的位置
.disable_td{
background-color: #ddd;
cursor: not-allowed;
}
或者,如果您想隐藏它,请使用
.disable_td{
display:none;
}
在函数的顶部
$(document).on("click", "#html_master .edit", function () {
var $this = $(this);
加
这两种方法都不管用。我不认为CSS会起作用,因为它只能在按下编辑按钮后进行编辑。当我按下编辑按钮ntry$(“输入”)。textinput(“禁用”);只需将$(“input”)更改为正确的classIt表示textinput不是functiontry.prop(“disabled”,true)
$(document).on("click", "#html_master .edit", function () {
var $this = $(this);
$( ".mr_id" ).addClass( "mr_id disable_td" );
$( ".mr_name" ).addClass( "mr_name disable_td" );