国产探花免费观看_亚洲丰满少妇自慰呻吟_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://m.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://m.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程序設計有所幫助。


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

圖片精選

主站蜘蛛池模板: 大化| 金华市| 威信县| 宜兴市| 闵行区| 页游| 玉溪市| 鹤壁市| 集贤县| 板桥市| 黑龙江省| 施甸县| 广汉市| 安顺市| 定西市| 夏河县| 道孚县| 洪江市| 汝州市| 庆安县| 前郭尔| 渝北区| 烟台市| 江孜县| 抚州市| 五指山市| 呼伦贝尔市| 甘谷县| 鹿泉市| 丰镇市| 光泽县| 华安县| 临泉县| 元阳县| 高台县| 崇明县| 兴山县| 宣武区| 桐柏县| 南华县| 凭祥市|