简体   繁体   English

jQuery click事件在手机上正常工作

[英]jQuery click event working except on mobile

I've encountered an issue that's really just a giant mystery to me. 我遇到的一个问题对我而言确实是一个巨大的谜。

Check out my Web Design portfolio http://drootech.com , if you notice on a desktop the red "See what else we do." 如果您在桌面上注意到红色的“请参阅我们的其他工作”,请查看我的Web设计产品组合http://drootech.com button works fine using the following code on a desktop browser. 在桌面浏览器上使用以下代码,可以使按钮正常工作。 But the odd thing is it doesn't work on mobile. 但奇怪的是,它不适用于移动设备。

$(document).ready(function(){
    $("#seemore").on('click touchstart', function (){
        //$(this).animate(function(){
            $('html, body').animate({
                scrollTop: $("#mrkting").offset().top - 85
                 }, 2000);
        //});
    });

I have another click/touchstart event is triggering the same scroll destination, is that why it's not working? 我还有另一个click / touchstart事件正在触发相同的滚动目标,这就是为什么它不起作用的原因? And if so how would I get around this issue? 如果是这样,我将如何解决这个问题? Here's the other code that may be potential conflictual? 这是其他可能潜在冲突的代码吗?

 $("#info").on('click touchstart', function (){
        //$(this).animate(function(){
            $('html, body').animate({
                scrollTop: $("h2#mrkting").offset().top - 85
                 }, 2000);
            $('#nav-menubg').slideUp('slow');
        //});
    });

Any help would be appreciated. 任何帮助,将不胜感激。

In the HTML portion of the code, on the elements you want to react when clicked on, add the javascript attribute onclick="" 在代码的HTML部分中,在您希望单击时做出反应的元素上,添加javascript属性onclick =“”

ie. 即。

<tag id="seemore" onclick=""></tag>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM