码迷,mamicode.com
首页 > 其他好文 > 详细

this的应用

时间:2017-05-25 19:00:18      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:url   false   this   ++   nts   hid   src   分享   cli   

技术分享
<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            li {
                list-style: none;
                width: 114px;
                height: 140px;
                background: url(img/normal.png);
                float: left;
                margin-right: 20px;
            }
        </style>
        <script>
            window.onload = function() {
                var oLi = document.getElementsByTagName(li);
                for(var i = 0; i < oLi.length; i++) {
                    oLi[i].onOff = true;
                    oLi[i].onclick = function() {
                        if(this.onOff) {
                            this.style.background = url(img/active.png);
                            this.onOff = false;
                        } else {
                            this.style.background = url(img/normal.png);
                            this.onOff = true;
                        }
                    }
                }
            }
        </script>
    </head>

    <body>
        <ul>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </body>

</html>
示例代码

 

this的应用

标签:url   false   this   ++   nts   hid   src   分享   cli   

原文地址:http://www.cnblogs.com/linjiaxiaomeiainia/p/6905363.html

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