码迷,mamicode.com
首页 > Web开发 > 详细

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

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

标签:main   doc   操作方法   button   ext   document   更改   ***   btn   

 

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 常见属性操作方法 ******

标签:main   doc   操作方法   button   ext   document   更改   ***   btn   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!