gpt4 book ai didi

javascript - 删除 的内容

转载 作者:行者123 更新时间:2023-11-28 16:09:38 25 4
gpt4 key购买 nike

我是 javascript/jquery 的新手。我有一个包含索引列(0、1、2、3 等)的表。我想使用 javascript 删除表的那部分。我尝试使用 after() 和 replaceWith() 但无法真正正确使用。

CSS 类是 .jobStats。我只想删除下面代码中 th 标签的内容。

   <tr>
<th>0 </th>
<td> 2015-06-02</td>
<td> ARCA</td>
<td> FAILED</td>
<td>2015-06-03 10:30:51.573000</td>
<td> NaT</td>
<td> NaT</td>
<td> NaN</td>
<td> NaN</td>
<td> NaN</td>
<td> 8704</td>
<td> 223226518</td>
<td> NaN</td>
<td> NaN</td>
</tr>

我有什么想法可以实现吗?

提前致谢!

最佳答案

只需使用 remove()

$('.jobStats').remove();

如果你想保留 .jobStats 并想删除它的 child ,使用 empty()

$('.jobStats').empty();

更新

I only want to remove the contents of the th tag in the table.

$('th').empty();

将删除子项和文本

This method removes not only child (and other descendant) elements, but also any text

关于javascript - 删除 <th> 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30624055/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com