• 【前端】纯前端的一个‘喜欢我吗?’


    喜欢❤
    不喜欢→_→

      这是我模仿DIYGOD做的一个‘臭不要脸的喜欢我吗?’,哈哈哈哈哈有点意思。

    -我从未见过如此厚颜无耻之人!

    -我从未见过如此厚颜无耻之人!

    -我从未见过如此厚颜无耻之人!

      只是纯前端的代码。不能记录喜欢的数量。复习了一下js代码(还是很生疏的感觉)。

      随便求厉害的人指教!

    <html>
    <script>
    function mOver(obj) {
        obj.innerHTML = "喜欢❤"
        obj.style.backgroundColor = "red";
        obj.style.color = "#fff";
        document.getElementById("boxleft").innerHTML = "不喜欢→_→ "
        document.getElementById("boxleft").style.backgroundColor = "#fff";
        document.getElementById("boxleft").style.color = "red";
    }
    
    function mOut(obj) {
        obj.innerHTML = "不喜欢→_→ "
        obj.style.backgroundColor = "#fff";
        obj.style.color = "red";
        document.getElementById("boxleft").innerHTML = "喜欢❤";
        document.getElementById("boxleft").style.backgroundColor = "red";
        document.getElementById("boxleft").style.color = "#fff";
    }
    
    function mDown(obj) {
        obj.style.backgroundColor = "#444";
    }
    
    function mUp(obj) {
        obj.style.backgroundColor = "red";
        obj.style.color = "#fff";
        document.getElementById("mybox").innerHTML = "</br>我也喜欢你(//▽//)";
    }
    </script>
    <style type="text/css">
    #mybox {
       cursor:pointer;
        margin:0 auto;
        text-align: center;
        padding: 20px;
        font: bold 15px arial, "微软雅黑";
         255px;
        height:50px;
    }
    
    #boxleft {
        float: left;
        padding: 20px;
         87px;
        color: #fff;
        background: red;
    }
    
    #boxright {
        padding: 20px;
        color: red;
         87px;
        float: right;
        background: #fff;
    }
    </style>
    
    <body >
        <div id="mybox">
            <div onmousedown="mDown(this)" onmouseup="mUp(this)" id="boxleft">
                喜欢❤
            </div>
            <div onmousedown="mDown(this)" onmouseup="mUp(this)" onmouseover="mOver(this)" onmouseout="mOut(this)" id="boxright">
                不喜欢→_→ 
            </div>
        </div>
    </body>
    
    </html>
  • 相关阅读:
    MTU 理解和遇到的一些问题
    tm使用
    C++字符串中转义符
    安卓系统修改host文件简单教程
    公有继承的一个理解
    模板打印函数
    linux 设置时区
    ACE中的inline
    SecureCRT中脚本进行交互,发送Ctrl+C
    C++中多态的实现原理
  • 原文地址:https://www.cnblogs.com/flipped/p/5224706.html
Copyright © 2020-2023  润新知