【发布时间】:2013-12-27 09:35:20
【问题描述】:
我有一个问题。我有 3 个图像(img1、img2、img3),其中一个是透明的,另外两个图像放在透明图像的下方。 img1 放置在下方(如背景图像),img2 放置在 img2 上方,最后是 img3(透明图像)。我想为 img2 执行操作,但触摸事件没有发生在透明图像(img3)之上。有没有办法在 img2 上触发触摸事件? 请帮我解决这个问题.. 提前谢谢..
代码..
$('#bgTrnsImg').bind('touchend',function(e){
$('#smallDustBean1').trigger('touchend');
});
$('#smallDustBean1').bind('click touchend',function(e){
SpriteSheetExample1();
alert("T1");
// Does something special
e.stopPropagation();
});
$('#bgTrnsImg').bind('touchend',function(e){
$('#smallDustBean2').trigger('touchend');
});
$('#smallDustBean2').bind('click touchend',function(e){
SpriteSheetExample2();
alert("T2");
// Does something special
e.stopPropagation();
});
$('#bgTrnsImg').bind('touchend',function(e){
$('#smallDustBean3').trigger('touchend');
});
$('#smallDustBean3').bind('click touchend',function(e){
SpriteSheetExample3();
alert("T3");
// Does something special
e.stopPropagation();
});
$('#bgTrnsImg').bind('touchend',function(e){
$('#smallDustBean4').trigger('touchend');
});
$('#smallDustBean4').bind('click touchend',function(e){
SpriteSheetExample4();
alert("T4");
// Does something special
e.stopPropagation();
});
$('#bgTrnsImg').bind('touchend',function(e){
$('#smallDustBean5').trigger('touchend');
});
$('#smallDustBean5').bind('click touchend',function(e){
SpriteSheetExample5();
alert("T5");
// Does something special
e.stopPropagation();
});
我正在更新我的代码,根据下面的答案,事件会在每次触摸透明图像时触发,而不是仅在特定的 img2(smallDustBeans) 上触发。 在 HTML 文件中,img1 z-index 为 1,img2 z-index 为 2,img3 z-index 为 3
【问题讨论】: