Add a function that closes the Menu...

User 2834904 Photo


Registered User
10 posts

Hi,

I am using the following script in RSD and would like to add a function that automatically - when clicking on a category in the navigation bar in the mobile - closes/hiding the nav.bar. Is it possible to add something to this script that automatically closes/hiding the navigation bar in the mobile when clicking on a category? If anyone know, please explain exactly how.

Here is the script:

In the Head area:
<style>
@media screen and (max-width: 768px) {#menu.show {display: block;}}
</style>

In the Footer area:
<script>
$(document).ready(function() {
$(".mobil-button").click(function() {
$("#menu").slideToggle('fast', function() {
$(this).attr('style', '').toggleClass('show');
});
$(this).toggleClass('active');
});
});
</script>
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Is the category link an anchor link to a spot on the same page?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2834904 Photo


Registered User
10 posts

Yes. It is five category links on the navigation bar and all of them are linked to anchors on the same page.
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Can you share a link to the page?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2834904 Photo


Registered User
10 posts

Ok, here is a link to the page - it is not finished yet, but I am working on it. If you see any problem with this page, please let me know. Thanks!

http://www.energibalansering.se/test/index.html
User 2843676 Photo


Registered User
11 posts

Hi Gia, I just viewed it using FF web developer responsive @ 320 x 480 and it looked and worked just fine. I don't understand why you would want to auto-close the responsive menu every time someone selects a link. Back to top works just fine and allows me to select another link without needing to open the menu again.

Don
User 2834904 Photo


Registered User
10 posts

Hi Don,

Thank you for your feedback, I appreciate it!
I would like to have the menu "fixed" at the top on the page so the visitor always have the menu at the top in the mobile screen when scrolling on the page. If I now, in RSD, change the settings so the menu is "fixed" at the top on the mobile screen and then opening the menu and clicking on a category, the navigation bar is going to be as a layer on the page and hide the information on the link after clicking on a category. (I have tried to do this and it was annoying to have the navigation bar as a layer on the text information on the page and that is why I would like to have an auto-close function).

/Gia

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.