Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
(не показана 1 промежуточная версия этого же участника) | |||
Строка 4: | Строка 4: | ||
function showRaceInfo(race) { | function showRaceInfo(race) { | ||
var infoBox = document. | var infoBox = document.getElementById('race-info-box'); | ||
var description = document.getElementById(race); | var description = document.getElementById(race); | ||
if (description) { | if (description) { | ||
Строка 15: | Строка 15: | ||
var cards = document.querySelectorAll('.race-card'); | var cards = document.querySelectorAll('.race-card'); | ||
cards.forEach(function (card) { | cards.forEach(function (card) { | ||
card.addEventListener("click", function () { | card.addEventListener("click", function (event) { | ||
event.preventDefault(); | |||
showRaceInfo(card.getAttribute("data-race")); | |||
}); | }); | ||
}); | }); | ||
}); | }); | ||
})(); | })(); |
Текущая версия от 21:18, 15 февраля 2025
(function () { if (window.raceInfoLoaded) return; window.raceInfoLoaded = true; function showRaceInfo(race) { var infoBox = document.getElementById('race-info-box'); var description = document.getElementById(race); if (description) { infoBox.innerHTML = description.innerHTML; infoBox.style.display = 'block'; } } document.addEventListener("DOMContentLoaded", function () { var cards = document.querySelectorAll('.race-card'); cards.forEach(function (card) { card.addEventListener("click", function (event) { event.preventDefault(); showRaceInfo(card.getAttribute("data-race")); }); }); }); })();