我目前正在制作一个表格,我可以在按钮点击事件中编辑内容,但只有最顶层行正在运行
这是我的代码
<tr id="tr">
<td class="text-center" >
<input type="hidden" value="' . $row['LOG_ID'] . '" id="logid" name="logid" >
<label class="col-large-2 control-label text-sm " id="lab1" > ' . $row['DATE'] . '</label><input type="text" hidden id="datepicker" placeholder="Date" value="' . $row['DATE'] . '">
</td>
<td class="text-center">
<label class="col-large-2 control-label text-sm " id="lab2"> ' . $row['W_IN'] . ' </label> <input type="text" hidden id="w_in" value="' . $row['W_IN'] . '">
</td>
<td class="text-center">
<label class="col-large-2 control-label text-sm" id="lab3"> ' . date("H:i:s", strtotime($row['W_OUT'])) . ' </label><input type="text" hidden id="w_out" value="' . $row['W_OUT'] . '">
</td>
<td class="text-center">
<label class="col-large-2 control-label text-sm" id="lab4"> ' . $row['O_IN'] . ' </label><input type="text" id="o_in" hidden value="' . $row['O_IN'] . '">
</td>
<td class="text-center">
<label class="col-large-2 control-label text-sm" id="lab5"> ' . $row['O_OUT'] . ' </label><input type="text" id="o_out" hidden value="' . $row['O_OUT'] . '">
</td>
<td class="text-sm text-center">
<a href="#" title="Save DTR" data-tooltip="true" hidden data-placement="bottom" id="saves" ><span class="glyphicon glyphicon-save"></span></a>
<a href="#" title="Delete DTR" data-tooltip="true" data-placement="bottom" id="edit" onclick="myFunction(this)"><span class="glyphicon glyphicon-edit"></span></a>
<a href="#" title="Delete DTR" data-tooltip="true" data-placement="bottom" id="delete"><span class="glyphicon glyphicon-remove"></span></a>
</td>
</tr>
答案 0 :(得分:0)
使用按钮的onmousedown和onmouseup事件。
onmousedown="element.contentEditable=true;" onmouseup="element.contentEditable=false;"