【发布时间】:2016-11-30 11:55:03
【问题描述】:
我希望从 html 表格中删除 div 但保留内容?
<table id="datatable">
<thead>
<tr>
<th></th>
<th>Jane</th>
<th>John</th>
</tr>
</thead>
<tbody>
<tr>
<th>Apples</th>
<td><div>3</div></td>
<td><div>4</div></td>
</tr>
</tbody>
</table>
我试过了:
alert($('#datatable').html().replace('<div>', ''));
但是警告的内容仍然包含
<div>
标签
我无法从源中删除它们,因为它们用于其他目的。
【问题讨论】:
-
您想删除
div-标签吗?并让每个td取而代之的是div标签的内容?
标签: javascript jquery html replace tags