My goal is to enable users to navigate up and down a list by pressing the up and down arrow keys. For example, if "roma" is currently highlighted, I want it to change to "milan" when the user presses the down arrow key. Here is the HTML code I am working with:
<li id="place">
<p>roma</p>
<p>milan</p>
<p>napoli</p>
</li>
I am looking to achieve this functionality using JavaScript, possibly utilizing the onclick()
method. Can someone please advise me on which JavaScript attribute to use for this task and how to highlight an item using CSS? Thank you!