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

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

技术教程推荐

深入浅出gRPC -〔李林锋〕

程序员进阶攻略 -〔胡峰〕

算法面试通关40讲 -〔覃超〕

Vue开发实战 -〔唐金州〕

玩转webpack -〔程柳锋〕

Flutter核心技术与实战 -〔陈航〕

小马哥讲Spring AOP编程思想 -〔小马哥〕

eBPF核心技术与实战 -〔倪朋飞〕

现代React Web开发实战 -〔宋一玮〕

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