• HTML加JS实现点击切换“观看”与“收起”效果切换


    通过HTML与JS实现点击button按钮,实现切换效果,可以在js里面增加自己相应的业务代码,代码如下:

    <!DOCTYPE html>
    <html>
    
    <head>
        <meta charset="utf-8">
    </head>
    
    <body>
        <!-- HTML样式部分 -->
        <form action="www.baidu.com" method="POST">
            <div>
                <!-- 点击事件里面加return false;防止在from中的button事件点击后跳转问题 -->
                <button type="button" id="displayBtn" style="110px;height:34px; border-radius:8px; background-color:#127587; display:block;" onclick="DisplayAndHiddenBtn('d'); return false;"><font size="2" color="white">点击加载漫画</font></button>
                <button type="button" id="hiddenBtn" style="110px;height:34px; border-radius:8px; background-color:#DC143C; display:none;" onclick="DisplayAndHiddenBtn('h'); return false;"><font size="2" color="white">点击收起漫画</font></button>
            </div>
        </form>
    </body>
    
    <!-- js代码部分 -->
    <script>
        function DisplayAndHiddenBtn(type) { 
            if (type == "d") {
                displayBtn.style.display = "none"; //style中的display属性
                hiddenBtn.style.display = "block";
                console.log('观看')
            }
            else if (type == "h") {
                displayBtn.style.display = "block"; //style中的display属性
                hiddenBtn.style.display = "none";
                console.log('收起')
            }
        }
    </script>
    </html>

    复制如上代码,最终效果如下:

    ps:上面操作是通过一个gif小程序生成的,需要的话,可以留言!!!

  • 相关阅读:
    svn使用方法
    董事、执行董事、总裁、总经理
    华联、联华、世纪华联、百联
    声明式编程和命令式编程
    NodeJS中的require和import
    JSONP跨站访问
    Camera服务之--架构浅析
    HashMap实现原理分析
    设计模式解读之一: 策略模式
    Java6.0中Comparable接口与Comparator接口详解
  • 原文地址:https://www.cnblogs.com/camg/p/13083628.html
Copyright © 2020-2023  润新知