原生js touch事件中touchend不触发
functionload(){varBattleL=document.getElementsByName('BattleL');for(vari=0;i<BattleL....
function load(){
var BattleL = document.getElementsByName('BattleL');
for (var i = 0; i<BattleL.length; i++) {
BattleL[i].addEventListener('touchstart',fn, false);
BattleL[i].addEventListener('touchmove',fn, false);
BattleL[i].addEventListener('touchend',fn, false);
function fn(event){
var event = event || window.event;
var OldBattleImg = this.src;
switch(event.type){
case "touchstart":
alert("1");
break;
case "touchmove":
alert("2");
break;
case "touchend":
alert("3");
break;
}
}
}
}
window.addEventListener('load',load, false);
请问那出错了,请高手帮帮忙!!! 展开
var BattleL = document.getElementsByName('BattleL');
for (var i = 0; i<BattleL.length; i++) {
BattleL[i].addEventListener('touchstart',fn, false);
BattleL[i].addEventListener('touchmove',fn, false);
BattleL[i].addEventListener('touchend',fn, false);
function fn(event){
var event = event || window.event;
var OldBattleImg = this.src;
switch(event.type){
case "touchstart":
alert("1");
break;
case "touchmove":
alert("2");
break;
case "touchend":
alert("3");
break;
}
}
}
}
window.addEventListener('load',load, false);
请问那出错了,请高手帮帮忙!!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询