我有一个TABLE
结构,我想将其元素转换为DIV
使用 jQuery 函数
HTML 示例:
<table>
<tr>
<td>
<table>
<tbody>
<tr>
<td>1000+</td><td> </td><td>$0.115</td>
</tr>
<tr>
<td>2000+</td><td> </td><td>$0.106</td>
</tr>
<tr>
<td>5000+</td><td> </td><td>$0.099</td>
</tr>
<tr>
<td>10000+</td><td> </td><td>$0.092</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>Some Data</td>
</tr>
</table>
我只想替换的结构是单元格 ( TD
) 标记内的那些表。所以做了一个代码来过滤和替换那些驻留在TD
标签内的表
$('table td:has(table)').replaceWith(function() {
//Replace function starts here
})
问题是我想替换所有元素,如, <TABLE>
,<TBODY>
和into or元素。<TH>
<TR>
<TD>
<DIV>
<SPAN>
我怎样才能做到这一点?
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div>
<div>
<div>
<div>1000+</div><div> </div><div>$0.115</div>
</div>
<div>
<div>2000+</div><div> </div><div>$0.106</div>
</div>
<div>
<div>5000+</div><div> </div><div>$0.099</div>
</div>
<div>
<div>10000+</div><div> </div><div>$0.092</div>
</div>
<div>
</div></td>
</tr>
<tr>
<td>Some Data</td>
</tr>
</table>