第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何使用 Javascript 創(chuàng)建數(shù)學(xué)測(cè)驗(yàn)

如何使用 Javascript 創(chuàng)建數(shù)學(xué)測(cè)驗(yàn)

BIG陽 2021-11-18 20:26:10
我必須為學(xué)校項(xiàng)目創(chuàng)建一個(gè)數(shù)學(xué)測(cè)驗(yàn)。我已經(jīng)創(chuàng)建了問題和答案。我只是不知道如何讓他們一次顯示一個(gè)問題。當(dāng)你回答問題時(shí),我必須一一展示。我還需要使用不同類型的問題,例如多項(xiàng)選擇、帶有敘述反應(yīng)的問題、帶有圖像選擇的問題、填空等。所以我需要幫助,一次顯示一個(gè)問題,顯示記分牌,在下一個(gè)問題出現(xiàn)之前向用戶顯示他們的問題是對(duì)還是錯(cuò),如果他們至少得到 80% 或沒有得到通過或失敗的消息,并為用戶提供最后重新參加測(cè)驗(yàn)的選項(xiàng)。這是我的 HTML<!DOCTYPE html><html><head><title>Math Quiz!</title><link href ="quizCSS.css" rel ="stylesheet"><link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet"><script src = "MathQuiz.js" defer></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script></head><body><h1>Take the Quiz!</h1><form id = "quiz" name = "quiz"><div id="q1"><p class = "questions">1) What is 2 + 2?</p><input id = "textbox" type = "text" name = "question1"><input type="button" onclick="myAnswer1()" value="Submit Answer"><script>var question1 = document.quiz.question1.value;function myAnswer1() {if(question1 == 4){document.write("You are correct!");}else{document.write("Wrong Answer!");}}</script></div><input type="button" onclick="myFunction1()" value="Start Question 1"><script>function myFunction1() {  document.getElementById("q1").style.display = "block";}</script><div id="q2"><p class = "questions">2) What is 3 to the power of 2?</p><input type = "radio" id = "mc" name = "question2" value = "9"> 9<br><input type = "radio" id = "mc" name = "question2" value = "6"> 6<br><input type = "radio" id = "mc" name = "question2" value = "3"> 3<br></div><input type="button" onclick="myFunction2()" value="Start Question 2"><script>function myFunction2() {  document.getElementById("q2").style.display = "block";  document.getElementById("q1").style.display = "none";}</script><div id="q3"><p class = "questions">3) What is the square root of 25?</p><input type = "radio" id = "mc" name = "question3" value = "5"> 5<br><input type = "radio" id = "mc" name = "question3" value = "525"> 525<br></div>
查看完整描述

2 回答

?
Cats萌萌

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超9個(gè)贊

jQuery 來救援!


只需使用$("#id").show()和hide():


var q = 1; //question #

function start() {

    $("#q2").hide();

    $("#q3").hide();

    //add more for more questions

}

function nextQ() {

    q++;

    update();

}

function update() {

    //hide all

    $("#q1").hide();

    $("#q2").hide();

    $("#q3").hide();

    //show next Q

    $("#q"+q).show();

}


HTML片段:


<button onclick="start();">Start</button>

<div id="q1">

    <!-- question -->

    1

    <button onclick="nextQ();">Next</button>

</div>

<div id="q2">

    <!-- question -->

    2

    <button onclick="nextQ();">Next</button>

</div>

<div id="q3">

    <!-- question -->

    3

    <button onclick="nextQ();">Next</button>

</div>

PS 使用onload屬性start()在頁面加載后立即運(yùn)行。


查看完整回答
反對(duì) 回復(fù) 2021-11-18
?
慕的地6264312

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超6個(gè)贊

有幾種方法可以做到這一點(diǎn)。使用 js 和 css,您可以display: block;將每個(gè)問題的元素的值更改為hidden,block每當(dāng)用戶必須回答問題時(shí)將它們更改回- 一個(gè)是block,而其他的都應(yīng)該隱藏。

要做到這一點(diǎn),請(qǐng)嘗試使用

document.getElementsByID("myDiv1").style.display = "hidden";

document.getElementsByID("myDiv2").style.display = "block";

分別地,myDiv1您想要環(huán)繞應(yīng)該隱藏的問題的 div 示例和myDiv2環(huán)繞當(dāng)前問題的 div的示例在哪里。

有關(guān)如何執(zhí)行此操作的更多信息,請(qǐng)查看w3schools 樣式顯示屬性參考


查看完整回答
反對(duì) 回復(fù) 2021-11-18
  • 2 回答
  • 0 關(guān)注
  • 155 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)