javascript - 可编辑行在包含 JSON 数据的表中不起作用?

标签 javascript jquery css json html

我解析了 JSON 对象并制作了一个表结构来显示元素。我想让表格的行可编辑。这是我用来形成表格的代码。

    (jsonDatag.data).forEach(function(item) {
                    var _tr = '<tr class="' + item.symbol + '"><td>' + item.symbol + '</td><td class="' + hclass + '">' + item.highPrice + '</td><td class="' + lclass + '">' + item.lowPrice + '</td><td class="' + oclass + '">' + item.openPrice + '</td><td class="' + ltclass + '">' + item.ltp + '</td><td>' + item.previousPrice + '</td><td>' + item.lastCorpAnnouncementDate + '</td></tr>'
                _tbody += _tr
            });
            _thead = _thead + _tbody;
            $('.mytable').html(_thead)
        }

现在我添加了这些行以使我的行可编辑,但它没有反射(reflect)在我的输出中。

                  $('tr.'+item.symbol+'').each(function() {
                $(this).html('<input type="text" value="' + $(this).html() + '" />');
});

这里出了什么问题,我该如何纠正?

最佳答案

Editable rows is not working in table

这似乎令人困惑,因为它是可编辑的 td

还有这个片段

$('tr.' + item.symbol + '').each(function() {
  $(this).html('<input type="text" value="' + $(this).html() + '" />');
});

可能会放置一个输入

如果你想制作一个可编辑的td那么

<td contenteditable="true">

会起作用

关于javascript - 可编辑行在包含 JSON 数据的表中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38367719/

相关文章:

javascript - Jquery - 根据检查两个数组乘以静态数字来查找成本

javascript - gmap3 获取集群位置

html - CSS font-size 属性从百分比到像素,如何?

html - IE10 超链接点击向上移动

javascript - 有关暂停的相关视频在 JW 播放器 6 中不起作用

javascript - 从 Sequelize 返回值

javascript - 后端认证,从哪里开始?

javascript - JQuery 需要多个选择器

css - 位置 css 箭头向下 div 的一半

javascript - Winston 添加自定义日志级别