首页 热点资讯 义务教育 高等教育 出国留学 考研考公
您的当前位置:首页正文

手持设备响应速度优化之-click和touch

来源:化拓教育网
手持上click事件的响应速度远远不如touchstart。但是仅仅写touch事件很不方便web端开发测试,所以下边的判断很有必要。###

<pre>
var isSupportTouch = "ontouchend" in document ? true : false,
touchEv = isSupportTouch ? 'touchstart' : 'mousedown',
touchEndEv = isSupportTouch ? "touchend" : 'mouseup';
</pre>
另外:
<pre>
var isSupportTouch = "ontouchend" in document ? true : false,
touchEv = isSupportTouch ? 'touchstart' : 'click';
</pre>
用起来就很方便啦
<pre>
$obj.on(touchEv,function(){
\事件
});
</pre>

显示全文