altough i've seen question many times can't find answer. have dropdown menu, , i'm trying add events opens hover on desktop , click on mobile devices.
i tried using code works somehow after resize window ( doesn't check immediately, if resize window does, somehow given code, how can edit ).
$(window).on('resize', function(event){ var windowsize = $(window).width(); // could've done $(this).width() if(windowsize < 300){ $('.menu-button').addclass('bbb'); } else if(windowsize < 768){ $('.dd-mlink').click(function() { $(this).toggleclass('show'); $('.dd-nav').toggleclass('dd-nav-full'); $('.dd-menu').toggleclass('dd-menu-full'); }); } else { $('.dd-mlink').hover(function() { $(this).toggleclass('show'); $('.dd-nav').toggleclass('dd-nav-full'); $('.dd-menu').toggleclass('dd-menu-full'); }); } });
.dd-mlink trigger, it's vertical full width dropdown need more toggleclasses.
is there other option? more efficient? libraries work me?
i tried lots of way, including creating div, adding different properties on different sizes (with media queries), , checking properties, doesn't work. appreciated. cheers!
i solve problem add on load next on resize @ window fuction, this
$(window).on('load resize', function(event){
here's code if ever use
$(window).on('load resize', function(event){ var windowsize = $(window).width(); // could've done $(this).width() if(windowsize < 992){ // check here } else if(windowsize > 994){ // other statements } });
you can add many elses want. cheers. have one
Comments
Post a Comment