jQuery中removeProp()方法用法实例

2020-05-24 21:19:27易采站长站整理

<meta name=”author” content=”//www.jb51.net/” />
<head>
<title>软件开发网</title>
<style type=”text/css”>
   td
   {
       width:200px;
   }
</style>
<script type=”text/javascript” src=”mytest/jQuery/jquery-1.8.3.js”></script>
<script type=”text/javascript”>
    $(document).ready(function(){
       $(“td”).prop({height:”300″});
       $(“button”).click(function(){
            $(“td”).removeProp(“width”);
       })
    })
</script>
</head>
<body>
    <table border=”1″>
      <tr>
       <td>欢迎来到软件开发网</td>
      </tr>
    </table>
    <button>删除属性</button>
</body>
</html>

以上代码并没有删除td的width属性,这是因为removeProp()只能删除由prop()方法设置的属性。

希望本文所述对大家的jQuery程序设计有所帮助。