首页 > Web开发 > 详细

jQuery 常见属性操作方法 ******

时间:2016-11-04 16:11:05      阅读:255      评论:0      收藏:0      [点我收藏+]

 

1. toggleClass()

对设置或移除被选元素的一个或多个类进行切换。

个人理解:对所选元素做一个css样式更改。

eg:

<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").toggleClass("main");
});
});
</script>
<style type="text/css">
.main
{
font-size:120%;
color:red;
}
</style>
</head>

<body>
<h1 id="h1">This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button class="btn1">切换段落的 "main" 类</button>
</body>
</html>

 

jQuery 常见属性操作方法 ******

原文:http://www.cnblogs.com/dh2608/p/6030453.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!