Код: Выделить всё
const btnElement = document.querySelector(".button");
const spnElement = document.querySelector(".span");
const choices = ["Cessna 172p", "F22", "F14", "Boeing 747"];
function choose(choices) {
var index = Math.floor(Math.random() * choices.length);
return choices[index];
};
btnElement.addEventListener("click", () => {
spnElement.textContent = choose();
});Код: Выделить всё
body {
background-color: #333;
color: whitesmoke;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
text-align: center;
}
button {
background-color: #786;
color: black;
border: 0;
border-radius: 5px;
}
button:hover {
border: 2px solid #578;
}Код: Выделить всё
Your plane
Click to find out plane
Это мой текущий код, я думаю, может возникнуть проблема с тем, как Я вызываю функцию, но не уверен.
Подробнее здесь: https://stackoverflow.com/questions/780 ... ent-change
Мобильная версия