1

誰かがこれで私を助けてください:

touchStart = function (evt) {
    evt.preventDefault();
    $(this).addClass("touched");
};

touchEnd = function (evt) {
    evt.preventDefault();
    $(this).removeClass("touched");
};

s.ontouchstart = touchStart;
s.ontouchend = touchEnd;
s.ontouchmove = touchEnd;

JavaScript によって動的に生成される section 要素があります (ul > li > section)。touchstart-touchmove-touchend イベント リスナーをこの section 要素にバインドすると、Android では機能しますが、iPad/iPod/iPhone では機能しません。

属性を使用して生成しようとしonclick="void(0)"ましたが、セクション要素がクリック可能な要素のように「相互作用」しましたが、それでも何もしません。

それはAndroidであらゆる方法で動作しますが、この野菜は今私には少し消費するようです... =)

前もって感謝します!=)

4

1 に答える 1

4

気にしないで、jQueryでそれを手に入れました。このようにして、どこでも実行されます。

$(s).bind("touchstart mousedown", function (e) {
    console.log(e.type); // to get the name of the event
}).bind("touchmove mousemove", function (e) {
    // ...
}).bind("touchend mouseup", function (e) {
    // ...
});
于 2012-06-01T15:28:24.553 に答える