jQuery 中的 removeAttr( name )方法函

首页 / jQuery入门教程 / jQuery 中的 removeAttr( name )方法函

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

removeAttr( name ) - 语法

selector.removeAttr( name )

这是此方法使用的所有参数的描述-

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

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

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

Node.js开发实战 -〔杨浩〕

分布式技术原理与算法解析 -〔聂鹏程〕

说透敏捷 -〔宋宁〕

如何看懂一幅画 -〔罗桂霞〕

技术面试官识人手册 -〔熊燚(四火)〕

Spring编程常见错误50例 -〔傅健〕

大数据经典论文解读 -〔徐文浩〕

说透元宇宙 -〔方军〕

Dubbo源码剖析与实战 -〔何辉〕

好记忆不如烂笔头。留下您的足迹吧 :)