zoukankan      html  css  js  c++  java
  • 代码搜集-手机网页触屏

    function initTouchEvent(){
        if(!!('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch){
            var items = $(".article_item");
            for(var i=0;i<items.length;i++){
                addToucheEvent(items[i],$(items[i]).attr("id"));
            }
        }
    }
    
    function addToucheEvent(item,id){
        item.addEventListener('touchstart',touch, false);
        item.addEventListener('touchend',touch, false);
        item.addEventListener('touchmove',touch, false);
    
        function touch (event){
            var event = event || window.event;
            switch(event.type){
                case "touchstart":
                    $("#"+id).css({"background":"#F5F5F5"});
                    break;
                case "touchend":
                    $("#"+id).css({"background":"#FFF"});
                    break;
                case "touchmove":
                    //event.preventDefault();
                    $("#"+id).css({"background":"#FFF"});
                    break;
            }
        }
    }
  • 相关阅读:
    几数之和的题目
    File类
    递归
    Collections
    Map集合
    泛型
    类型通配符
    可变参数
    异常
    Collection集合
  • 原文地址:https://www.cnblogs.com/zhouyalei/p/4387917.html
Copyright © 2011-2022 走看看