Run JavaScript function only if NOT on mobile

In this case, I'm only checking if the navbar toggle is visible or not to decide whether to run the function. So, you just let the CSS handle the screen sizes. Much easier!

In this example, the menu dropdown only activates on hover if the navbar toggle is not visible. The page has to be refreshed after you've changed the viewport size in order to display properly but this won't be a problem if you're truly on a mobile browser.