Is there a way to apply a highlight with a style of "background-color: aqua" in the textarea only to the word selected from the list above after clicking on it? See below for my HTML:
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<ul id="box">
<li>Add</li>
<li>Sum</li>
<li>Div</li>
<li>Text4</li>
<li>Text5</li>
</ul>
<textarea rows="4" cols="50" id="id-of-your-textarea"></textarea>
</body>
And here is my script:
<script>
const textArea = document.getElementById('id-of-your-textarea');
const boxLi= document.getElementById('box').children;
for(let i = 0; i < boxLi.length; i++){
boxLi[i].addEventListener('click', () => {
textArea.value +=boxLi[i].textContent;
})
}
</script>