您好,欢迎访问一九零五行业门户网

jquery中tr怎么删除id属性

在jquery中,可以利用removeattr()方法删除tr元素的id属性,该方法的作用就是从被选元素中移除属性,将括号中的参数设置为“id”即可,语法为“需要删除id属性的tr元素对象.removeattr(id);”。
本教程操作环境:windows10系统、jquery3.2.1版本、dell g3电脑。
jquery中tr怎么删除id属性removeattr() 方法从被选元素中移除属性。
语法
$(selector).removeattr(attribute)
attribute 必需。规定从指定元素中移除的属性。
示例如下:
<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>
输出结果:
相关视频教程推荐:jquery视频教程
以上就是jquery中tr怎么删除id属性的详细内容。
其它类似信息

推荐信息