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>