在jquery中,可以使用removeAttr()方法来移除td元素中的指定属性,该方法的作用就是从所有匹配的元素中移除指定的属性,具体语法为“$("td").removeAttr("需要移除的属性")”。

本教程操作环境:windows7系统、jquery1.10.2版本、Dell G3电脑。
在jquery中,可以使用removeAttr()方法来移除td元素中的指定属性。
removeAttr() 方法可以从所有匹配的元素中移除指定的属性。
语法:
$(selector).removeAttr(attribute)
-
attribute :规定从指定元素中移除的属性,不可省略。
jQuery 1.12.4下载jQuery 1.12.4是jQuery 1.x系列的最后一个正式稳定版本,由jQuery团队于2016年发布。该版本主要面向需要兼容旧版浏览器环境的网站和Web应用,尤其适用于仍需支持Internet Explorer 6、Internet Explorer 7、Internet Explorer 8等老旧浏览器的项目。
示例:移除td元素中的id属性
html>
<meta><script></script><script>
$(document).ready(function() {
$("button").click(function() {
$("td").removeAttr("id")
});
});
</script><style>
#Peter{
background-color: #FFC0CB;
}
</style>
| 姓名 | 年龄 |
|---|---|
| Peter | 20 |
| Lois | 20 |

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










