-1

I have a Wordpress site running Flatsome theme where there are some pages with sidebars created using Custom Sidebar plugin which are not showing up on a menu hover. I have try to fix that glitch using jQuery code below

<script>
jQuery(document).ready(function () {

    jQuery(".widget_nav_menu .menu-item-has-children").hover(
        function () {
            jQuery('ul.sub-menu', this).slideDown('medium');
        }, 

        function () {
                jQuery('ul.sub-menu', this).slideUp('medium');
        }
    );

});
</script>

which works fine on any computer browser but not on mobile devices (iPhone and iPad) and I have no clue what can cause that.

JackTheKnife
  • 3,795
  • 8
  • 57
  • 117

1 Answers1

0

You can't hover on mobile.

jQuery(".widget_nav_menu .menu-item-has-children").hover( // change

Trigger above differently on Mobile, such as using double tap. hold

..or mousedown / mouse leave.


sample mobile friendly alteration: (untested but hopeflly you get the idea, it's not the .slideDown that is failing, it's the .hover)

jQuery(document).ready(function () {

    jQuery(".widget_nav_menu .menu-item-has-children").mouseout(function(){
        function () {
            jQuery('ul.sub-menu', this).slideDown('medium');
        }, 

        function () {
                jQuery('ul.sub-menu', this).slideUp('medium');
        }
    );

});

Your second part question may be -- how to maintain .hover trigger on desktop and trigger a mobile one as I'm suggesting on only mobile.

Community
  • 1
  • 1
Dr Upvote
  • 8,023
  • 24
  • 91
  • 204