touch events firing twice

前端 未结 3 1971
天涯浪人
天涯浪人 2020-12-31 18:51

I am having problems on mobile devices/tablets with the events firing twice. When I click the following function, the menu that is supposed to drop down will drop down then

3条回答
  •  礼貌的吻别
    2020-12-31 19:13

    In most cases the following code will be ok:

    $(document).on("touchend click", ".lines-button", function(e){
        if(e.type == 'touchend'){
            $(this).off('click');
        }
    });
    

    If touchend works, you may get rid of click.

提交回复
热议问题