Quantcast
Channel: Opinion: Shopify Community - Shopify Design
Viewing all articles
Browse latest Browse all 57838

Close dropdown menu on second click? by travis johnson

$
0
0

I'm designing a custom responsive version of a client's store with a simple dropdown menu. As of now if you click on the main "Menu" link it opens the dropdown menu and it stays open. I'd like to close the dropdown menu if someone clicks on the "Menu" link a second time.

How can this be done? Javascript?

Here's my code:

<ul>
          {% for link in linklists.mobile-nav.links %}<li class="{% if forloop.first %}first{% elsif forloop.last %}last{%endif%}">
            {% assign child_list_handle = link.title | handleize %}
            {% if linklists[child_list_handle].links != blank %}<div class="has-dropdown"><a href="{{ link.url }}" id="menu_button" class="clearfix"><span class="nav-label">{{ link.title | escape }}</span><span class="nav-arrow"></span></a><ul class="mobile_dropdown">
                {% for childlink in linklists[child_list_handle].links %}<li><a href="{{ childlink.url }}">{{ childlink.title | escape }}</a></li>
                {% endfor %}</ul></div>
            {% endif %}</li>
          {% endfor %}</ul>

 


Viewing all articles
Browse latest Browse all 57838

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>