I have many select all
buttons within my HTML that essentially do the same thing. However they all have different ids because the buttons represent different divs
that have different content within them. I am new to JS and I was wondering how can I perform the same logic across many select all
buttons when one of them is clicked?
I thought about putting each select all
button in an array containing all the ids and using
arr = [id1,id2,id3];
for (var i = 0; i < arr.length; i++) {
var k = document.getElementById(arr[i]);
k.onclick = function() {//...logic...}
}
I'm new to JS so I'm not sure if this is a good method to approach