zoukankan      html  css  js  c++  java
  • ontouchstart

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
        <meta content="yes" name="apple-mobile-web-app-capable">
        <meta content="black" name="apple-mobile-web-app-status-bar-style">
        <meta content="telephone=no" name="format-detection">
        <meta content="email=no" name="format-detection">
        <style type="text/css">
            a{-webkit-tap-highlight-color: rgba(0,0,0,0);}
            .btn-blue{display:block;height:42px;line-height:42px;text-align:center;border-radius:4px;font-size:18px;color:#FFFFFF;background-color: #4185F3;}
            .btn-blue-on{background-color: #357AE8;}
        </style>
    </head>
    <body>
    
    <div class="btn-blue">按钮</div>
    
    <script type="text/javascript">
        var btnBlue = document.querySelector(".btn-blue");
        btnBlue.ontouchstart = function(){
            this.className = "btn-blue btn-blue-on"
        }
        btnBlue.ontouchend = function(){
            this.className = "btn-blue"
        }
    </script>
    </body>
    </html>

    其实可以用active,考虑要做到全兼容,故而用了通过绑定ontouchstart和ontouchend来控制按钮的类名。

  • 相关阅读:
    hiho150周
    hdu1011
    hiho1055/hdu1561
    bat脚本启动exe并打开文件后退出 + 中文乱码
    hiho1080
    hiho1079
    java异常处理——基础篇
    找不到要编译的文件——path环境变量配置
    MVC——studying
    轻松搞定EasyUI
  • 原文地址:https://www.cnblogs.com/wang715100018066/p/6016732.html
Copyright © 2011-2022 走看看