
"I'm new here and fairly new to JavaScript, so please bear with me. I've been converting a working python program to JavaScript with varying degrees of success. It's a fairly simple 8x8 button panel that modifies the button text when toggled. So far that works. However, some of the buttons are in "groups" that work like a mechanical switch that clears the other buttons in the group when a new one is selected."
"As a button is pressed, it creates an event that passes the button info. I'm mostly concerned with button.textContent. When an event occurs, button.textContent becomes available as the current button pressed. My question is: Inside of this event, how would I access any/all of the other buttons in the 8x8 array? While I realize that this is not 'correct' (doesn't work) I'm looking for something like:button[row][col].textContent Or an equivalent to access the other members of the group."
An 8x8 button grid is implemented by creating button elements, assigning dataset.row and dataset.col, and storing per-button mode and initial text. Buttons toggle their displayed text when clicked. Some buttons belong to mutual-exclusion groups where selecting one should clear others, behaving like mechanical switches. The click handler receives the clicked element via event.target and can read event.target.textContent and a mode value from a command array. The unresolved task is how to reference and update other buttons in the grid from inside the click event, equivalent to accessing button[row][col].textContent.
Read at SitePoint Forums | Web Development & Design Community
Unable to calculate read time
Collection
[
|
...
]