Welcome to my website. It features a top menu and a sidebar menu. On desktop, the side bar is visible by default but on mobile devices, the side bar overlaps the website content making it difficult to hide due to the toggle button being in the top menu.
Can I have the side bar hidden when the page first loads? (Issue 1)
If this can be resolved, the show/hide sidebar function works perfectly on desktop. However, resizing the browser window causes the text on the toggle button to display incorrectly - 'HIDE SIDEBAR' shows when it's hidden and vice versa.
The jquery code snippet used for hiding/showing the sidebar is:
var f=1; // displays 'HIDE' by default.
$(document).ready(function(){
$("#menu-toggle").click(function(){
if (f==0)
{
$("#menu-toggle").html("<b>Show Categories</b>");
f=1;
}
else
{
$("#menu-toggle").html("<b>Hide Categories</b>");
f=0;
}
});
});
Is there a way to determine the device type before running the script so that I can set the initial value of f accordingly? (Issue 2)