首页 > 其他 > 详细

touch事件

时间:2014-06-12 20:33:01      阅读:366      评论:0      收藏:0      [点我收藏+]

可封装的js代码

if (typeof YwkMobile == "undefined") var YwkMobile = {};
YwkMobile.touchStyle = function(e, t) {
$(e).bind("touchstart",
function() {
$(this).addClass(t)
}),
$(e).bind("touchmove",
function() {
$(this).removeClass(t)
}),
$(e).bind("touchend",
function() {
$(this).removeClass(t)
}),
$(e).bind("touchend",
function() {
$(this).removeClass(t)
}),
$(e).bind("touchcancel",
function() {
$(this).removeClass(t)
})
},
YwkMobile.gotoDetail = function(e, t) {
$(e).bind("click",
function() {
window.location.href = $(this).attr(t)
})
}
//

 

html中调用方法

//touch事件
$(function(){
YwkMobile.touchStyle(‘.navlist li a ,.product-list li‘,‘mtouchs‘);
});

 

css

添加类mtouchs可以写成touch事件触摸后的样式

.product-list li.mtouchs{}

是添加类mtouchs,所以中间不能有空格

 












touch事件,布布扣,bubuko.com

touch事件

原文:http://www.cnblogs.com/snowbaby-kang/p/3781670.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!