Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript单击“编辑”按钮时,如何使行可编辑?_Javascript_Jquery_Html Table_Row - Fatal编程技术网

使用javascript单击“编辑”按钮时,如何使行可编辑?

使用javascript单击“编辑”按钮时,如何使行可编辑?,javascript,jquery,html-table,row,Javascript,Jquery,Html Table,Row,我想在单击编辑按钮时使行可编辑,我如何才能做到这一点?您需要在td内创建输入字段,然后在保存时使用javascript加载值并存储它们。所以你可以 $('dependents info')。在('click','btn edit dependent',函数(){ var currentTD=$(this).parents('tr').find('td'); var newInput=currentTD.appendChild(“输入”); setAttribute(“id”,“newInput

我想在单击编辑按钮时使行可编辑,我如何才能做到这一点?

您需要在td内创建输入字段,然后在保存时使用javascript加载值并存储它们。所以你可以

$('dependents info')。在('click','btn edit dependent',函数(){
var currentTD=$(this).parents('tr').find('td');
var newInput=currentTD.appendChild(“输入”);
setAttribute(“id”,“newInput1”);

});您需要在td中创建输入字段,然后当您想要保存它们时,使用javascript加载值并存储它们。所以你可以

$('dependents info')。在('click','btn edit dependent',函数(){
var currentTD=$(this).parents('tr').find('td');
var newInput=currentTD.appendChild(“输入”);
setAttribute(“id”,“newInput1”);

});
您可以通过添加
contenteditable=“true”
使
td
可编辑。请参阅下面的代码

$('#dependents-info').on('click', '.btn-edit-dependent', function () {
                var currentTD = $(this).parents('tr').find('td');
                //what code will I put here?
            });

希望这有帮助。

您可以通过添加
contenteditable=“true”
使
td
可编辑。请参阅下面的代码

$('#dependents-info').on('click', '.btn-edit-dependent', function () {
                var currentTD = $(this).parents('tr').find('td');
                //what code will I put here?
            });
希望这有帮助