// Radio-Buttons Spieler 1 holen let radioButton_S1_7 = document.querySelector('#id_effort-0'); let radioButton_S1_6 = document.querySelector('#id_effort-1'); let radioButton_S1_5 = document.querySelector('#id_effort-2'); let radioButton_S1_4 = document.querySelector('#id_effort-3'); let radioButton_S1_3 = document.querySelector('#id_effort-4'); let radioButton_S1_2 = document.querySelector('#id_effort-5'); let radioButton_S1_1 = document.querySelector('#id_effort-6'); // Unterste Zellen (1) holen let cell1 = document.querySelector('#table_payoffMatrix tr:nth-last-child(1)'); // Unterste Zellen (2) holen let cell2 = document.querySelector('#table_payoffMatrix tr:nth-last-child(2)'); // Unterste Zellen (3) holen let cell3 = document.querySelector('#table_payoffMatrix tr:nth-last-child(3)'); // Unterste Zellen (4) holen let cell4 = document.querySelector('#table_payoffMatrix tr:nth-last-child(4)'); // Unterste Zellen (5) holen let cell5 = document.querySelector('#table_payoffMatrix tr:nth-last-child(5)'); // Unterste Zellen (6) holen let cell6 = document.querySelector('#table_payoffMatrix tr:nth-last-child(6)'); // Unterste Zellen (7) holen let cell7 = document.querySelector('#table_payoffMatrix tr:nth-last-child(7)'); // Funktion, die den Hintergrund aller zellen zurücksetzt function resetAllCells() { cell1.style.backgroundColor = 'transparent'; cell2.style.backgroundColor = 'transparent'; cell3.style.backgroundColor = 'transparent'; cell4.style.backgroundColor = 'transparent'; cell5.style.backgroundColor = 'transparent'; cell6.style.backgroundColor = 'transparent'; cell7.style.backgroundColor = 'transparent'; } // Funktion, um Hintergrundfarbe hellgrün oder transparent zu machen function updateCells(radioButton, cell) { if(radioButton.checked){ resetAllCells(); cell.style.backgroundColor = '#e0ffe0'; } } // Event-Listener hinzufügen und Funktion updateCells ausführen radioButton_S1_7.addEventListener('change', function(){ updateCells(radioButton_S1_7, cell7); }); radioButton_S1_6.addEventListener('change', function(){ updateCells(radioButton_S1_6, cell6); }); radioButton_S1_5.addEventListener('change', function(){ updateCells(radioButton_S1_5, cell5); }); radioButton_S1_4.addEventListener('change', function(){ updateCells(radioButton_S1_4, cell4); }); radioButton_S1_3.addEventListener('change', function(){ updateCells(radioButton_S1_3, cell3); }); radioButton_S1_2.addEventListener('change', function(){ updateCells(radioButton_S1_2, cell2); }); radioButton_S1_1.addEventListener('change', function(){ updateCells(radioButton_S1_1, cell1); });