我是靠谱客的博主 动听长颈鹿,这篇文章主要介绍jquery中tr怎么删除id属性,现在分享给大家,希望可以做个参考。

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

jquery中tr怎么删除id属性

removeAttr() 方法从被选元素中移除属性。

语法

复制代码
1
$(selector).removeAttr(attribute)
登录后复制

attribute 必需。规定从指定元素中移除的属性。

示例如下:

复制代码
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
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <style> #city{ background-color:pink; } </style> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("tr").removeAttr("id"); }); }); </script> </head> <body> <table border="1"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr id="city"> <td>January</td> <td>$100</td> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table> <button>删除所有tr元素的id属性</button> </body> </html>
登录后复制

输出结果:

+8.gif

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

以上就是jquery中tr怎么删除id属性的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是动听长颈鹿最近收集整理的关于jquery中tr怎么删除id属性的全部内容,更多相关jquery中tr怎么删除id属性内容请搜索靠谱客的其他文章。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部