jQuery中removeProp()方法用法实例
作者:bea
本文实例讲述了jQuery中removeProp()方法用法。分享给大家供大家参考。具体分析如下: 此方法可以删除由prop()方法设置的属性。 语法: 代码如下: $("selector").removeProp(name) 参数列表: 参数 描述 name 定义要要删除的属性名称。 实例: 实例一: 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
本文实例讲述了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:///" />
<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:///" />
<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程序设计有所帮助。
有用 | 无用
此方法可以删除由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:///" />
<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:///" />
<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程序设计有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- JavaScript静态类型检查工具FLOW简介
- jQuery中filter()方法用法实例
- JavaScript修改浏览器tab标题小技巧
- ECMAScript 6即将带给我们新的数组操作方法前瞻
- jQuery中hasClass()方法用法实例
- jQuery中last()方法用法实例
- jQuery中first()方法用法实例
- jquery解决客户端跨域访问问题
- angular.foreach 循环方法使用指南
- angularjs 处理多个异步请求方法汇总
- json实现前后台的相互传值详解
- jQuery中eq()方法用法实例
- 一款基于jQuery的图片场景标注提示弹窗特效
- jQuery中toggleClass()方法用法实例
- jQuery中removeClass()方法用法实例
- jQuery中addClass()方法用法实例
- js Calender控件使用详解
- js的回调函数详解
- 判断浏览器的内核及版本号方法汇总