我是靠谱客的博主 甜美鲜花,这篇文章主要介绍jquery怎么隐藏table列,现在分享给大家,希望可以做个参考。

本教程操作环境:windows10系统、jquery3.2.1版本、Dell G3电脑。

jquery怎么隐藏table列

find() 方法返回被选元素的后代元素。

eq() 方法返回带有被选元素的指定索引号的元素。

索引号从 0 开头,所以第一个元素的索引号是 0(不是 1)。

复制代码
1
$(selector).eq(index)
登录后复制
  • index 必需。规定元素的索引。可以是整数或负数。

hide() 方法隐藏被选元素。

复制代码
1
$(selector).hide(speed,easing,callback)
登录后复制
  • speed 可选。规定隐藏效果的速度。

  • easing 可选。规定在动画的不同点上元素的速度。默认值为 "swing"。

  • callback 可选。hide() 方法执行完之后,要执行的函数。

示例如下:

复制代码
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
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>123</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $(".btn1").click(function(){ $('tr').find('th:eq(0)').hide(); $('tr').find('td:eq(0)').hide(); }); $(".btn2").click(function(){ $('tr').find('th:eq(0)').show(); $('tr').find('td:eq(0)').show(); }); }); </script> </head> <body> <table border="1"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table> <button class="btn1">隐藏</button> <button class="btn2">显示</button> </body> </html>
登录后复制

输出结果:

+7.gif

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

以上就是jquery怎么隐藏table列的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是甜美鲜花最近收集整理的关于jquery怎么隐藏table列的全部内容,更多相关jquery怎么隐藏table列内容请搜索靠谱客的其他文章。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部