Javascript 使当前HTML行可编辑

Javascript 使当前HTML行可编辑,javascript,jquery,html-table,Javascript,Jquery,Html Table,在屏幕截图中,我希望能够使用编辑图像的onClick事件使同一行的5个文本框可编辑。默认情况下,我将它们设置为“只读”。我已经寻找了其他解决方案,但我不确定如何引用当前行 <table class = "idtable" cellspacing="0"> <tr style="background-color:#999999;color:white"> &l

在屏幕截图中,我希望能够使用编辑图像的onClick事件使同一行的5个文本框可编辑。默认情况下,我将它们设置为“只读”。我已经寻找了其他解决方案,但我不确定如何引用当前行

<table class = "idtable" cellspacing="0">                                                
    <tr style="background-color:#999999;color:white">
      <th width="200px" class="tablehead">Type</th>
      <th width="200px" class="tablehead">Value</th>
      <th width="200px" class="tablehead">State</th>
      <th width="200px" class="tablehead">Status</th>
      <th width="200px" class="tablehead">Entry Date</th>
      <th width="100px" class="tablehead">Edit</th>
      <th width="100px" class="tablehead">Delete</th>
    </tr>   

    <tr style="text-align:center">
      <td class="idtable-borderleft"><input id="idType" class="readonly" type="text" value="INSTSERVICES" readonly></td>
      <td class="idtable-bordermid"><input id="idValue" class="readonly" type="text" value="1234        " readonly></td>
      <td class="idtable-bordermid"><input id="idState" style="font-size:85%" class="readonly" type="text"  value="UNMODIFIED" readonly></td>
      <td class="idtable-bordermid"><input id="idStatus" class="readonly" type="text" value="Active" readonly></td>
      <td class="idtable-bordermid"><input id="idStartDate" class="readonly" type="text" value="2015-03-17" readonly></td>
      <td class="idtable-bordermid"><img onclick="editRow()" src="https://localhost:8443/xxxxx/images/edit.png"></td>
      <td class="idtable-borderright"><a href="/xxxxx/timeServ.do?formName=updateIDs&delete=true&assocID=5320&credID=1234" ><img src="xxxxx/images/delete.gif"></a></td>
    </tr>                                                   
    <tr>
      <td colspan="7"><input style="margin-left:50%; margin-top: 5px" type="submit" value="Update"></td>
    </tr>                                                   
</table>

类型
价值
陈述
地位
参赛日期
编辑
删除

您需要使用类似jQuery editable的东西

尝试双击下面演示中的文本


您需要启动ajax调用来更新数据库中的数据。

不要使用
onClick
标记

使用jQuery附加到click事件,然后遍历DOM以查找行,最后操作
input
标记

在本例中,我假设您向图像中添加了一类
btnedit

$('.idtable .btnedit').click(function(){
    var row = $(this).closest('tr'); //find the parent row
    var inputs = $('input', row); //find all the inputs inside the row
    inputs.prop('readonly', false); //change the attribute
});

小提琴:我们需要这张桌子的结构。你能帮我们发布相关的HTML吗?还有什么解决方案?请展示您尝试过的内容。从代码示例开始,这样会更容易提供帮助。我的意思是我已经看过其他解决方案,但它们不是我真正想要的。既然您已经在使用jquery,您可以尝试jqgrid。