【发布时间】:2018-08-30 00:57:08
【问题描述】:
我有一个带有以下标题的表格。我设置了代码以发送 ajax 请求以检索 JSON 数据,并在用户单击按钮时显示一个带有表格的对话框,然后我过滤此数据,以便它返回过滤后的数据(例如 Kevin)。以上所有工作都很好。现在我想将此数据(Kevin)插入相应的单元格标题(例如名称)和其他数据(数字->xxx-xxx-xxxx;地址->xxx...等)。我想这样做,所以我确保将数据插入到正确的字段中。用户关闭对话框后,我需要清空该行。
Javascript:
executeAPI("GetUserInfo.php", "name", callback); // this returns Kevin
function exeCtCoreAPIcallback(result){
//need to append the result to the corresponding cell header here.
}
HTML:
<table id="data-table">
<thead>
<tr id="data-row" class="data-header">
<th>Name</th>
<th>Number</th>
<th>Address</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
</tr>
</tbody>
</table>
有没有办法引用<th> 的名称并在下面插入?
【问题讨论】:
标签: javascript jquery html html-table cell