My jQuery toggleclass function is creating a hyperlink effect on touchscreen devices

后端 未结 1 1220
有刺的猬
有刺的猬 2021-01-16 22:57

I have used jQuery to add a css transition effect when the mouse hovers over the header of my site, causing it to turn from transparent to a white background. I\'m having a

相关标签:
1条回答
  • 2021-01-16 23:04

    Since it seems that the .active class don't apply only on iPhones.
    (See comments below the question).
    Your browser is probably Safari.

    I found this SO answer that may solve your problem. Here is how to implement it:

    jQuery(document).ready(function($){    
    
    $(".header").hover(function(){
            $(".header, h5.logo#lucieaverill, h5.logo#photography").addClass("active");
                // Forces Safari to redraw
            $("body").addClass("dummyClass").removeClass("dummyClass");
    
        }, function(){  // Callback
            $(".header, h5.logo#lucieaverill, h5.logo#photography").removeClass("active");
                // Forces Safari to redraw
            $("body").addClass("dummyClass").removeClass("dummyClass");
        });
    });
    

    Why does it forces Safari to redraw isn't explained...
    But it look's like a working walk-around for this browser specific bug.

    0 讨论(0)
提交回复
热议问题