【发布时间】:2018-04-30 03:31:37
【问题描述】:
大家好,我想根据行号替换行内的数据。我发布的代码遍历表中的行,计算行索引并将它们与所需的行匹配。如果条件为真,则应替换该行中的数据。 我已经编辑了问题
我不知道我应该用什么来替换数据?
我尝试过 .innerHTML、.replaceWith() 但它们没有给我所需的东西。
$('table#table-mytable tr').each(function(){
var row_required = tag[tag.length-2];
console.log('this is row_required: '+row_required);
var row = $(this).index()+1;
console.log('this is row: '+row);
if(row==row_required) {
(What should I enter here)
}
});
我想替换为: replaceWith('td colspan="2" input type="text" name="input_" class="input_" id="input_" value="' + input_tag + '" placeholder="输入标签" /td>') ?
【问题讨论】:
-
您正在循环行。然而,一行没有内容。它有包含内容的单元格 (
<td>)。所以你正在寻找类似row.find('td').html('The new text')
标签: jquery