嗨,我怎样才能做到这一点:
$('x').live("touchstart", function (e) {
//do stuff
if (event= ontouchmove){
//do stuff
}
else (event= ontouchend){
//do stuff
}
所以在触摸开始之后,无论是ontouchmove还是ontouchend,但如果ontouchmove fires ontouchend没有。事件监听器还是什么?
感谢您的帮助(是的,代码不正确,但作为一个例子:p)
编辑:试过你的一个答案,但它仍然无效......
$('input').live("touchstart", function (e) {$(this).addClass('click')});
$('input').live("touchmove,touchend", function (e) {
if (e.type == 'touchmove'){
$('.temp').removeClass('temp');
$('.click').removeClass('click');}
else{var inputvalue = $(this).val()
$('input[value="' + inputvalue + '"] + label').css({
'-webkit-transition': 'opacity 0.3s linear',
'opacity': '0'
});
setTimeout(function () {
$('input[value="' + inputvalue + '"] + label').css({'-webkit-transition': '0',
'opacity': '1'});
$('.temp').removeClass('temp');
$('.click').removeClass('click');
}, 300);}
});