当前位置: 首页 > 文档资料 > jQuery 入门教程 >

removeAttr(name )

优质
小牛编辑
122浏览
2023-12-01

描述 (Description)

removeAttr( name )方法从每个匹配的元素中删除一个属性。

语法 (Syntax)

以下是使用此方法的简单语法

<i>selector</i>.removeAttr( name )

参数 (Parameters)

以下是此方法使用的所有参数的说明 -

  • name - 要删除的属性的名称。

例子 (Example)

以下示例将删除每个表的边框 -

<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>