How to add hover effect for menu items on Mobile devices?

I am adding the hover effect to the menu items on the mobile version, but it is not working well due to some reasons. I tried various CSS code for this. Can someone help me with this problem?

Asked 09 May, 17 at 05:40 AM

Tim Martin
Html Css

Answer

Hey Tim,


You can use jQuery for this. For making the compatibility of the hover effect to mobile devices, we use "touchstart" event like in the given example. Use the following script:

$('.nav-menu li').on("touchstart", function (e) {
$('.nav-menu li').removeClass('active');
$(this).addClass('active');
});

Hope this will fix the problem.

like