removeAttr(name)方法从每个匹配的元素中删除一个属性。
selector.removeAttr( name )
这是此方法使用的所有参数的描述-
name - 要删除的属性的名称。
<html> <head> <title>The Selecter Example</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type="text/javascript" language="javascript"> $(document).ready(function() { $("table").removeAttr("border"); }); </script> </head> <body> <table border="2"> <tr><td>This is first table</td></tr> </table> <table border="3"> <tr><td>This is second table</td></tr> </table> <table border="4"> <tr><td>This is third table</td></tr> </table> </body> </html>
这将产生以下输出-
This is first table |
This is second table |
This is third table |
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)