Apologies in advance for the title being a bit vague, I struggled to find the right words.
Essentially, I have 10 buttons each with unique IDs. When these buttons are clicked, I want them to toggle the class of a textarea element. Is there a way to do this without having to create individual event listeners and functions for each button? Any guidance or suggestions would be much appreciated. I'll include the relevant code below for reference.
$(document).ready(function () {
note1btn.addEventListener("click", displayNote);
//DISPLAY NOTE
function displayNote() {
$("#note1input").toggleClass("hide");
}
});
.hide {
visibility: hidden;
height: 1px !important;
padding: 0px !important;
margin: 0px !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="note1btn" data-role="button">Note #1</button>
<textarea id="note1input" class="hide" rows="10" cols="50"></textarea>
... (buttons 2-10 with corresponding textareas) ...