mobile safari links retains focus after touch

前端 未结 8 527
天涯浪人
天涯浪人 2020-12-13 13:33

My navigation is quite simple. I have a hover state which adds a border and a transparent gradient png background to some text, and an additional class which, when added by

8条回答
  •  失恋的感觉
    2020-12-13 14:11

    you need to catch the following events

    touchstart - when your finger touches the screen

    touchend - when your finger leaves the screen

    think of as hover and unhover, if you can post some code we can help you more if you don't understand what I am saying

    $('element').on('touchstart', function(){
        // apply hover styles, or better yet addClass() of hover styles
    });
    
    $('element').on('touchend', function(){
        // removeClass or remove styles, in here you set it to default so even if it is focused, it makes no difference
    });
    

    Give some sample code, the touchstart and end should solve the problem

提交回复
热议问题