当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jQuery中removeAttr()方法用法实例教程

jQuery中removeAttr()方法用法实例教程

2019年03月28日  | 移动技术网IT编程  | 我要评论

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

此方法从匹配元素中移除相应的属性。

语法结构:

代码如下:

$(selector).removeattr(attribute)

参数列表:

参数 描述
attribute 定义要从匹配元素中移除的属性

 

实例代码:

 

代码如下:


<!doctype html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="https://www.cnblogs.com/" />
<title>博客园</title>
<style type="text/css">
p{
  height:200px;
  width:200px;
  border:1px solid blue
}
.reset{
  font-size:20px;
  color:green;
}
</style>
<script type="text/javascript" src="mytest/jquery/jquery-1.8.3.js"></script> 
<script type="text/javascript">
$(document).ready(function(){
  $("#btn").click(function(){
    $("p").removeattr("class");
  })
})
</script>
</head>
<body>
  <p class="reset">博客园欢迎您</p>
  <button id="btn">点击查看效果</button>
</body>
</html>

在以上代码中,点击按钮可以删除移除class属性。

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网