Jump to content

Making top menu bar more dynamic - highlighting when hovering, underline when clicked

Recommended Posts

Site URL: http://www.mghstudentwellness.org

We are trying to make the top menu bar of our website a bit more dynamic, by having different options highlight when you hover over them, and the top level category (e.g., Resources) remain underlined when anything within that menu is clicked, to help with navigation/not losing one's place. Currently this happens only for the "What we do" item.

I have very basic Square Space editing skills.

Can anyone help? Thank you!

Link to comment
11 hours ago, MGHCCCSEW said:

Site URL: http://www.mghstudentwellness.org

We are trying to make the top menu bar of our website a bit more dynamic, by having different options highlight when you hover over them, and the top level category (e.g., Resources) remain underlined when anything within that menu is clicked, to help with navigation/not losing one's place. Currently this happens only for the "What we do" item.

I have very basic Square Space editing skills.

Can anyone help? Thank you!

I saw you use jQuery and some other js code snippet to replace the folder url, kindly replace all of them with this 

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
	var folder_link = [
        {
            href: "/what-we-do",
            target: "/our-services-1"
        },
        {
            href: "/who-we-are",
            target: "/about-us"
        },
        {
            href: "/resources-2",
            target: "/resources"
        }
    ]
    $(document).ready(function() {
        $(document).on('click', '.header-nav-folder-title', function(e) {
            var folder_href = $(this).attr("href");
            var folder_item = folder_link.filter(function(f) { return f.href == folder_href; });

            if ( folder_item[0] ) {
                window.location = folder_item[0].target;
            }
            e.preventDefault();
            return false;
        });

        var current_path = window.location.pathname;
        var matched_folder_item = folder_link.filter(function(f) { 
            return current_path == f.target;
        });

        if ( matched_folder_item[0] ) {
            $('.header-nav-folder-title[href="'+matched_folder_item[0].href+'"]').closest("div").addClass("header-nav-item--active");
        }
    });
</script>

image.png.d5a7b9290a8a6add7d9e0cc44d8fa18e.png

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio plugin
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.