Mit diesem Workaround wird Hintergrundfarbe der ausgewählten Option bei entsprechender Auswahl in das Select-Feld übernommen.
1 2 3 4 5 6 7 8 9 | <select id="yourRating" onchange="document.getElementById('yourRating').style.backgroundColor = this[this.selectedIndex].style.backgroundColor;"> <option> </option> <option style="background-color:#1BBD00;" value="1">1</option> <option style="background-color:#9CBD04;" value="2">2</option> <option style="background-color:#EC0303;" value="3">3</option> <option style="background-color:#C0C0C0;" value="4">4</option> <option style="background-color:#BD8EB1;" value="5">5</option> </select> |
// Dank geht an sempfh