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

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

單擊時(shí)數(shù)字不增加

單擊時(shí)數(shù)字不增加

慕斯709654 2023-09-07 18:26:50
我有一個(gè)簡(jiǎn)單的多問(wèn)題測(cè)驗(yàn),當(dāng)選擇正確或不正確的答案時(shí),它會(huì)顯示某些文本。現(xiàn)在我正在嘗試添加增量分?jǐn)?shù),但沒有成功。我添加了一個(gè)警報(bào),無(wú)論答案正確還是錯(cuò)誤都會(huì)觸發(fā)警報(bào),但分?jǐn)?shù)不會(huì)增加。我的代碼中缺少什么?完整的代碼如下。為了簡(jiǎn)單起見,只包含一個(gè)問(wèn)題。function questionMarkers() {  let labels = document.querySelectorAll(    "div[class*='rsform-block-question'] .formControlLabel"  );  let count = labels.length;  for (let i = 0; i < count; i++) {    let marker = `<span class="question-marker">${i + 1}</span>`;    labels[i].insertAdjacentHTML("beforebegin", marker);  }}const runQuiz = (() => {  questionMarkers();  let score = 0;  let answers = document.querySelectorAll(".rsform-radio");  answers.forEach(function(answer) {    answer.addEventListener("click", (e) => {      let target = e.target;      let container = target.closest(".formContainer");      let correct = container.querySelector("div[class$='true']");      let wrong = container.querySelector("div[class$='false']");      let feedback = container.querySelector("div[class$='feedback']");      let question = container.querySelector(        "div[class*='rsform-block-question']"      );      let next = container.querySelector(".js-btn--next.success");      let submit = container.querySelector(        ".js-btn--submit.rsform-submit-button"      );      if (e.target.value == "t") {        correct.style.display = "block";        wrong.style.display = "none";        feedback.style.display = "block";        alert("Correct!");        score++;      } else {        correct.style.display = "none";        wrong.style.display = "block";        feedback.style.display = "block";        alert("Incorrect");      }      question.style.display = "none";    });    document.getElementById("score").innerText = score;  });})();
查看完整描述

2 回答

?
慕婉清6462132

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

沒有什么問(wèn)題score。調(diào)整時(shí)必須更新它score。


function questionMarkers() {

  let labels = document.querySelectorAll(

    "div[class*='rsform-block-question'] .formControlLabel"

  );

  let count = labels.length;

  for (let i = 0; i < count; i++) {

    let marker = `<span class="question-marker">${i + 1}</span>`;

    labels[i].insertAdjacentHTML("beforebegin", marker);

  }

}


const runQuiz = (() => {

  questionMarkers();

  let score = 0;

  let answers = document.querySelectorAll(".rsform-radio");

  answers.forEach(function(answer) {

    answer.addEventListener("click", (e) => {

      let target = e.target;

      let container = target.closest(".formContainer");

      let correct = container.querySelector("div[class$='true']");

      let wrong = container.querySelector("div[class$='false']");

      let feedback = container.querySelector("div[class$='feedback']");

      let question = container.querySelector(

        "div[class*='rsform-block-question']"

      );

      let next = container.querySelector(".js-btn--next.success");

      let submit = container.querySelector(

        ".js-btn--submit.rsform-submit-button"

      );


      if (e.target.value == "t") {

        correct.style.display = "block";

        wrong.style.display = "none";

        feedback.style.display = "block";

        alert("Correct!");

        score++;

        document.getElementById("score").innerText = score;

      } else {

        correct.style.display = "none";

        wrong.style.display = "block";

        feedback.style.display = "block";

        document.getElementById("score").innerText = score;

        alert("Incorrect");

      }

      question.style.display = "none";

    });

    document.getElementById("score").innerText = score;

  });

})();

<fieldset class="formContainer" id="rsform_53_page_0">

  <div class="row">

    <div class="medium-12 columns">

      <div class="row rsform-block rsform-block-question-one">

        <div class="medium-3 columns">

          <span class="question-marker">1</span><label class="formControlLabel" data-tooltip="" aria-haspopup="true" data-disable-hover="false" tabindex="1" title="">Why do skunks spray?</label>

        </div>

        <div class="medium-9 columns formControls">

          <input type="radio" name="form[question-one]" value="f" id="question-one0" class="rsform-radio"><label for="question-one0">To attract a mate</label><br><input type="radio" name="form[question-one]" value="t" id="question-one1" class="rsform-radio">

          <label for="question-one1">To defend themselves against predators</label><br><input type="radio" name="form[question-one]" value="f" id="question-one2" class="rsform-radio"><label for="question-one2">To mark their territory</label><br>

          <input type="radio" name="form[question-one]" value="f" id="question-one3" class="rsform-radio"><label for="question-one3">Because they like the smell</label>

          <span class="formValidation"><span id="component878" class="formNoError"></span></span>

        </div>

      </div>

      <div class="row rsform-block rsform-block-question-one-true" style="display: none;">

        <p><strong>Correct!</strong></p>

      </div>

      <div class="row rsform-block rsform-block-question-one-false" style="display: none;">

        <p><strong>Nice try</strong></p>

      </div>

      <div class="row rsform-block rsform-block-question-one-feedback" style="display: none;">

        <p>Skunks spray an extremely offensive odour to make predators go away and leave them alone. If they feel their life is in danger, they have no other defence as they cannot run fast, climb, burrow under the ground, or fight.</p>

      </div>

    </div>

  </div>

  <p id="score"></p>

</fieldset>


查看完整回答
反對(duì) 回復(fù) 2023-09-07
?
慕容708150

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

您的document.getElementById("score").innerText = score;陳述位于EventListener您提高分?jǐn)?shù)的 之外。所以你需要把它放在你的括號(hào)內(nèi)EventListener。



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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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