首页 > 其他 > 详细

zepto - toggleClass

时间:2014-12-16 19:08:32      阅读:399      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>zepto</title>
    <style>
        .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>
<script src="zepto.min.js"></script>
<script>
    $("button").click(function () {
        $("p").toggleClass("main");
    });
</script>
</body>
</html>

 

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>zepto</title>
    <style>
        .listitem_1, .listitem_3 {
            color: red;
        }

        .listitem_0, .listitem_2 {
            color: blue;
        }
    </style>
</head>
<body>
<h1 id="h1">This is a heading</h1>
<ul>
    <li>Apple</li>
    <li>IBM</li>
    <li>Microsoft</li>
    <li>Google</li>
</ul>
<button class="btn1">添加或移除列表项的类</button>
<script src="zepto.min.js"></script>
<script>
    $("button").click(function () {
        $(ul li).toggleClass(function () {
            return listitem_ + $(this).index();
        });
    });
</script>
</body>
</html>

 

zepto - toggleClass

原文:http://www.cnblogs.com/qzsonline/p/4167734.html

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