# Anchors not working on sub-menu

**URL:** <https://forum.freecodecamp.org/t/anchors-not-working-on-sub-menu/95963>\
**Category:** General\
**Created:** [March 12, 2017, 1:09pm UTC](https://forum.freecodecamp.org/t/anchors-not-working-on-sub-menu/95963 "2017-03-12T13:09:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rejuvenation](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/rejuvenation/32/84290_2.png) [@Rejuvenation](https://forum.freecodecamp.org/u/Rejuvenation)\
**Post date:** [March 12, 2017, 1:09pm UTC](https://forum.freecodecamp.org/t/anchors-not-working-on-sub-menu/95963/1 "2017-03-12T13:09:37Z")

</div>

Hello anyone, just since today I’m experiencing some Issues with sub-menu anchors. They apparently seems not to open properly…but they are shown in the bottom-left part of the browser…does anyone know why? I’m struggling to this from an hour but still couldn’t find any solution…  
[http://lamoresca.it/alpha/home.html](http://lamoresca.it/alpha/home.html)

---

<div class="post-metadata">

**Author:** ![honmanyau](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/honmanyau/32/45787_2.png) [@honmanyau](https://forum.freecodecamp.org/u/honmanyau)\
**Post date:** [March 12, 2017, 4:18pm UTC](https://forum.freecodecamp.org/t/anchors-not-working-on-sub-menu/95963/2 "2017-03-12T16:18:22Z")

</div>

Hey there! I was curious and am procrastinating from sleep so I had a quick look!

If I’m not mistaken, the following line in js/menu-toggle.js appears to be the culprit:

```
$(".site-nav li:nth-child(2)").toggle(function() {

```

It seems to be selecting _all_ `li` descendants that are a second child; in fact, if you inspect the behaviour of clicking any of the child `li` elements under the I Nostri Vini `li` element, you will find that all they are doing is the toggling of the menu for smaller screens as specified in the script.

This seems to fix the problem:

```
$(".main-menu > li:nth-child(2) > a").toggle(function() {

```

Applying an id to the I Nostri Vini `li` element and selecting it directly also seems to work:

```
<li id="i-nostri-vini">...</li>

$("#i-nostri-vini").toggle(function() {

```

I’m not entirely sure why the anchor element has to be selected in the first fix, though. Someone with more experience will hopefully comment on that!

I hope that helps! 🙂

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:51pm UTC](https://forum.freecodecamp.org/t/anchors-not-working-on-sub-menu/95963/3 "2021-01-17T20:51:29Z")

</div>

Closed on January 17, 2021, 8:51pm UTC


