使用jQuery填充tbody时,填充了两倍数据

it2023-07-16  70

前端页面相关代码

<table class="table table-condensed table-striped"> <tr> <th>用户编号</th> <th>用户姓名</th> <th>登陆账号</th> <th>电话</th> <th>微信号</th> <th>身份证号</th> <th>地址</th> <th>角色</th> <th>操作</th> </tr> <tbody></tbody> </table>

​ ps:注意此时表头使用的是tr标签

js代码

$("tbody").html(htmlData)

​ 执行词条语句,页面会显示双倍表格数据

解决方案 将 tr 改成 thead 表头标签 问题解决

相关代码

<table class="table table-condensed table-striped"> <thead> <th>用户编号</th> <th>用户姓名</th> <th>登陆账号</th> <th>电话</th> <th>微信号</th> <th>身份证号</th> <th>地址</th> <th>角色</th> <th>操作</th> </thead> <tbody></tbody> </table>

​ 问题解决!

最新回复(0)