清除表jquery [英] clear table jquery

查看:98
本文介绍了清除表jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 HTML表格,里面有很多行。

I have an HTML table filled with a number of rows.

如何删除表格中的所有行?

推荐答案

使用 .remove()

Use .remove()

$("#yourtableid tr").remove();

如果你想保留数据以备将来使用,那么你可以使用 .detach()

If you want to keep the data for future use even after removing it then you can use .detach()

$("#yourtableid tr").detach();

如果行是表的子项,则可以使用子选择器而不是后代选择器,如

If the rows are children of the table then you can use child selector instead of descendant selector, like

$("#yourtableid > tr").remove();

这篇关于清除表jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆