User:Hefner/Sandbox8: Difference between revisions
Jump to navigation
Jump to search
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
{| class="wikitable bingo-table" | <style> | ||
.bingo-table td { | |||
cursor: pointer; | |||
padding: 12px 18px; | |||
border: 1px solid #aaa; | |||
text-align: center; | |||
user-select: none; | |||
} | |||
.bingo-selected { | |||
background-color: #ffe599 !important; | |||
border: 2px solid #d4af37 !important; | |||
color: black; | |||
font-weight: bold; | |||
} | |||
</style> | |||
{| class="wikitable bingo-table" style="width: 300px; margin: 1em auto; border-collapse: collapse;" | |||
|- | |- | ||
| {{#tag:td| | | {{#tag:td|B1|id=tile-1}} || {{#tag:td|B2|id=tile-2}} || {{#tag:td|B3|id=tile-3}} | ||
|- | |- | ||
| {{#tag:td| | | {{#tag:td|I1|id=tile-4}} || {{#tag:td|I2|id=tile-5}} || {{#tag:td|I3|id=tile-6}} | ||
|- | |- | ||
| {{#tag:td| | | {{#tag:td|N1|id=tile-7}} || {{#tag:td|N2|id=tile-8}} || {{#tag:td|N3|id=tile-9}} | ||
|} | |} | ||
<script> | |||
document.addEventListener("DOMContentLoaded", function () { | |||
const cells = document.querySelectorAll(".bingo-table td"); | |||
cells.forEach(function (cell) { | |||
const id = cell.id; | |||
if (!id) return; | |||
// Restore selection from localStorage | |||
if (localStorage.getItem(id) === "selected") { | |||
cell.classList.add("bingo-selected"); | |||
} | |||
// Toggle selection on click | |||
cell.addEventListener("click", function () { | |||
cell.classList.toggle("bingo-selected"); | |||
if (cell.classList.contains("bingo-selected")) { | |||
localStorage.setItem(id, "selected"); | |||
} else { | |||
localStorage.removeItem(id); | |||
} | |||
}); | |||
}); | |||
}); | |||
</script> |
Revision as of 23:19, 16 June 2025
<style> .bingo-table td {
cursor: pointer; padding: 12px 18px; border: 1px solid #aaa; text-align: center; user-select: none;
}
.bingo-selected {
background-color: #ffe599 !important; border: 2px solid #d4af37 !important; color: black; font-weight: bold;
} </style>
B1 | B2 | B3 | |||
I1 | I2 | I3 | |||
N1 | N2 | N3 |
<script> document.addEventListener("DOMContentLoaded", function () {
const cells = document.querySelectorAll(".bingo-table td");
cells.forEach(function (cell) { const id = cell.id; if (!id) return;
// Restore selection from localStorage if (localStorage.getItem(id) === "selected") { cell.classList.add("bingo-selected"); }
// Toggle selection on click cell.addEventListener("click", function () { cell.classList.toggle("bingo-selected");
if (cell.classList.contains("bingo-selected")) { localStorage.setItem(id, "selected"); } else { localStorage.removeItem(id); } }); });
}); </script>