国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

jQuery中removeProp()方法用法實例

2024-05-06 16:13:42
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了jQuery中removeProp()方法用法,實例分析了removeProp()方法的功能、定義及刪除由prop()方法設置的屬性時的使用技巧,需要的朋友可以參考下
 
 

本文實例講述了jQuery中removeProp()方法用法。分享給大家供大家參考。具體分析如下:

此方法可以刪除由prop()方法設置的屬性。

語法:

復制代碼代碼如下:
$("selector").removeProp(name)

 

參數列表:

參數 描述
name 定義要要刪除的屬性名稱。

 

實例:

實例一:

 

復制代碼代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="http://www.survivalescaperooms.com/" />
<head>
<title>武林網</title>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
       $("td").prop({width:"200",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屬性。

實例二:

 

復制代碼代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="http://www.survivalescaperooms.com/" />
<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程序設計有所幫助。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 札达县| 汉阴县| 漠河县| 扶风县| 苗栗县| 柞水县| 鄯善县| 娄底市| 梁河县| 韶山市| 荆门市| 北海市| 绥江县| 定边县| 社旗县| 鄂伦春自治旗| 西和县| 隆德县| 登封市| 兴隆县| 察雅县| 兴义市| 修武县| 班玛县| 乐清市| 喀什市| 新晃| 布拖县| 阿坝县| 社旗县| 仪征市| 阿拉善左旗| 荔浦县| 颍上县| 布尔津县| 赞皇县| 长葛市| 米林县| 耒阳市| 石首市| 邵武市|