简体   繁体   中英

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." 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? 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=""

ie.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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