Showing notepad notes in JavaScript
Let's now make it so that when you click on the link, the text of the corresponding entry appears in textarea. It is obvious that somehow you need to associate each link with the corresponding element of the object with texts.
The simplest way is at the time of creating a link
to a note to assign a data-
attribute with
the number of the object element to it, for example,
like this:
<div id="menu">
<ul id="notes">
<li data-key="1">note 1</li>
<li data-key="2">note 2</li>
<li data-key="3">note 3</li>
</ul>
</div>
In this case, the algorithm of our task will be reduced
to the following: by clicking on the link, we will read
the contents of its data-key
attribute, then we
will get the text from the element of the object with
that number, and then we will write this text into
the text area.
Implement the assigned subtask.
Make sure that the link of the note that is currently being viewed is active - that is, it's highlighted in some way, for example, with the background.