[英]Editable rows is not working in table with JSON data?
I parsed JSON objects and made a table structure to display the elements. 我解析了JSON对象,并制作了一个表结构来显示元素。 I wanted to make rows of table editable. 我想使表格的行可编辑。 This is is the code i used to form the table. 这是我用来构成表格的代码。
(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)
}
Now I added these lines to make my rows editable but it is not reflecting in my output. 现在,我添加了这些行,以使行可编辑,但它并未反映在我的输出中。
$('tr.'+item.symbol+'').each(function() {
$(this).html('<input type="text" value="' + $(this).html() + '" />');
});
What is going wrong here and how can i correct it ? 这里出了什么问题,我该如何纠正?
Editable rows is not working in table 可编辑的行在表中不起作用
This seems to be confusing since it is the td
which is editable. 这似乎令人困惑,因为它是可编辑的td
。
Also this snippet 也是这个片段
$('tr.' + item.symbol + '').each(function() {
$(this).html('<input type="text" value="' + $(this).html() + '" />');
});
probably will place an input
. 可能会放置一个input
。
If you are looking to make a editable td
then 如果您要制作可编辑的td
<td contenteditable="true">
will work 将工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.