how to highlight menu on submenu clicked
Hi all, i have a <p> tag which is the menu and <li>s as submenus.
How i can target via Javascript the upper <p> element when li is clicked?
i have this script which is triggered when i click but i can't target the upper p element
2 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Couple of points about your HTML:
1) You're using a P as a header, you should use an appropriate H tag. I picked h2, because you should only ever have one h1, but you might already have an h2 above this in this section, in which case this should be h3
2) The heading needs to be outside of the list, it's not a list item itself
3) Your li's have empty class attributes, they're unnecessary
4) You nested your A and LI tags the wrong way around, you do
<li><a></li></a>
. The browser understands that as <li><a></a></li>
and discards the last </a>
, but it's better to be correct and explicit
5) You have a bunch of spans inside the A's you probably don't need. If you're using them to apply a class, use a class on the A or the LI