page = document.querySelector('.page')
let next = document.querySelector('.next')
let pages = document.querySelectorAll('.page')
let answerA = document.getElementById('#a')
let answerB = document.getElementById('#b')
let answerC = document.getElementById('#c')
let answerD = document.getElementById('#d')
let registration = document.querySelector('.registration')
function add(){
registration.classList.toggle('show')
}
Question.addEventListener('click', (event) => {
if(event.target.classList.contains('next')){
console.log('Далее');
}
})
window.onload = sendApiReq
async function sendApiReq(){
let response = await fetch('https://opentdb.com/api.php?amount=10&category=15&difficulty=easy&type=multiple')
console.log(response);
let data = await response.json()
console.log(data);
useApiData(data)
}
function useApiData(data){
questionItem.innerHTML += `
<div class="question__item">
${data.results[0].question}
</div>
`
check.innerHTML += `
<div class="send">
<label><input type='radio' id="a" value="a" name="checking">
${data.results[0].incorrect_answers[0]}
</label>
</div>
<div class="send">
<label><input type='radio' id="b" value="b" name="checking">
${data.results[0].incorrect_answers[1]}
</label>
</div>
<div class="send">
<label><input type='radio' id="c" value="c" name="checking">
${data.results[0].correct_answer}
</label>
</div>
<div class="send">
<label><input type='radio' id="d" value="d" name="checking">
${data.results[0].incorrect_answers[2]}
</label>
</div>
`
}
В закрепе есть сайты куда можно выложить
Обсуждают сегодня