首页 > 其他 > 详细

ontouchstart

时间:2016-10-31 18:26:27      阅读:309      评论:0      收藏:0      [点我收藏+]
<!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来控制按钮的类名。

ontouchstart

原文:http://www.cnblogs.com/wang715100018066/p/6016732.html

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