How can I organize an unordered list as a dropdown list with a choice of value?

  • 0
    There is an unordered list of languages.

    <ul id="lng-menu1" class="lng-menu">
    	<li class="active"><a href="/ru">RU</a></li>
    	<li><a href="/en">EN</a></li>

    The active class is assigned to li by clicking on the link with the language version (that is, this feature already exists and is not needed in the code).
    Both links are visible on the page:
    It is necessary that only the active language is shown, and when clicked, a "drop-down list" of languages ​​is shown, when choosing a language, the selected one is shown again and the link is followed. Again, the "active" class is already assigned to the selected language when the link is clicked.

    On the Internet, there were only solutions with an "initial" value, such as "select something", or bootstrap dropdowns with a button in front of the list. The button is superfluous here, you need a solution based on the above html structure.

    In theory, something in jquery / javascript. There are links inside the li-shek, so I can't determine the click on which it is better to process, by UL or by the links themselves. You also need an expandable solution if you add one or a couple more languages.
    JavaScript Gabriella Krueger, Jul 31, 2019

  • 1 Answers
  • 0
    Found a solution, slightly correcting the solution from this question (you can find the answer in the comments)

    Styling the ul like a dropdown?

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!