我是靠谱客的博主 还单身自行车,这篇文章主要介绍jquery怎么去掉td里的内容,现在分享给大家,希望可以做个参考。

本教程操作环境:windows7系统、jquery1.10.2版本、Dell G3电脑。

jquery去掉td里的内容

在jquery中,可以利用html()方法来去掉td里的内容。

html() 方法返回或设置被选元素的内容 (inner HTML)。

只需要使用html()方法将td元素的内容设置为空即可。

实现代码:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="js/jquery-1.10.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("button").click(function() { $("td").html(""); }); }); </script> </head> <body> <table border="1"> <caption>人物信息</caption> <tr> <th>姓名</th> <th>年龄</th> </tr> <tr> <td>Peter</td> <td>20</td> </tr> <tr> <td>Lois</td> <td>20</td> </tr> </table><br /> <button>点击按钮,去除td中的内容</button> </body> </html>
登录后复制

1.gif

相关教程推荐:jQuery视频教程

以上就是jquery怎么去掉td里的内容的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是还单身自行车最近收集整理的关于jquery怎么去掉td里的内容的全部内容,更多相关jquery怎么去掉td里内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(98)

评论列表共有 0 条评论

立即
投稿
返回
顶部