代码搜集-手机网页触屏
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; } } }