美文网首页前端
傻瓜看的fastClick说明书

傻瓜看的fastClick说明书

作者: 相睡恨晚 | 来源:发表于2015-03-17 12:02 被阅读14653次

1,引入库文件fastclick.js

2,注入事件进去(body或者某个元素)

3,若使用jQuery

$(function() {
    FastClick.attach(document.body);
});

4,一个demo

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>fastclick说明书</title>
    <script src="fastclick.js"></script>
</head>
<body>
    <button id="click">click me!</button>
    <script type="text/javascript">
        if ('addEventListener' in document) {
            document.addEventListener('DOMContentLoaded', function(){
                FastClick.attach(document.body);
            }, false);
        }
        document.querySelector("#click").addEventListener("click",function(){
            alert("click me!");
        },false)
    </script>
</body>
</html>

相关文章

网友评论

    本文标题:傻瓜看的fastClick说明书

    本文链接:https://www.haomeiwen.com/subject/bnbixttx.html