簡體   English   中英

IOS上的ontouch代碼與Android touch和Windows touch上的代碼不同嗎?

[英]ontouch code on IOS is not the same as on Android touch and windows touch?

我使用此代碼是因為它可以在您滑過div框時打開div框和div框上的陰影。

if (!("ontouch" in document.documentElement)) {
    document.documentElement.className += " no-touch";
}
$('html').on('touch touchend', function(e) {
        $(this).toggleClass('over');
});

但是我注意到,在三星銀河5上,它的工作不如在iPhone上好。

使用iPhone時,它只能在其上滑動。 但是在Windows觸摸手機上的android上,您實際上必須稍微按一下才能產生相同的效果。 有沒有辦法解決這個問題?

如果您同時擁有兩部手機,都可以在我的網站https://www.gester.nl上對其進行測試。

預先感謝您的回答。

來自荷蘭的問候。

jQuery可以解決大多數此類跨瀏覽器的問題-使用它就可以使用它。此外,您可能是指ontouchstart而不是ontouch

if (!("ontouchstart" in document.documentElement)) {
    $(document.documentElement).addClass("no-touch");
}
$('html').on('touch touchend', function(e) {
    $(this).toggleClass('over');         
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM