javascript代码实例教程-jQuery中removeProp()方法用法实例教程

发布时间:2018-12-29 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-jQuery中removeProp()方法用法实例教程脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

本文实例讲述了jQuery中removeProp()方法用法。分享给大家供大家参考。具体分析如下:

此方法可以删除由PRop()方法设置的属性。

语法:

代码如下:

$("selector").removeProp(name)

参数列表:

参数 描述
name 定义要要删除的属性名称。

实例:

实例一:

代码如下:


<!DOCTYPE htML PubLIC "-//W3C//DTD XHTML 1.0 TransITional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html XMlns="https://www.w3.org/1999/xhtml">
<;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="https://www.cnblogs.COM/" />
<head>
<title>博客园</title>
<script type="text/javascript" src="mytest/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript">
&nbsp;   $(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" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="https://www.cnbLOGs.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()方法设置的属性。

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的javascript代码实例教程-jQuery中removeProp()方法用法实例教程全部内容,希望文章能够帮你解决javascript代码实例教程-jQuery中removeProp()方法用法实例教程所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。