How do I add an event listener to numerous buttons and determine the value of each based on which one is clicked? and after clicking, it will apply a style to the text in the textarea.
<div id="wrapper" class="text-2xl font-semibold space-x-4">
<button id="bold-button">B</button>
<button id="italic-button" class="italic">I</button>
<button id="underline-button" class="underline">U</button>
</div>
**<textarea name="" id="textarea" cols="" rows="10">My Text</textarea>**
I am currently facing difficulties in applying styling to the contents within the textarea. This challenge arises from my inability to locate any pathways to connect the textarea when the button is clicked.
const wrapper = document.getElementById('wrapper');
wrapper.addEventListener('click', (event) => {
const isButton = event.target.nodeName === 'BUTTON';
if (!isButton) {
return;
}
console.dir(event.target.id);
})