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

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

使用單選按鈕時(shí)無(wú)法更改innerHTML

使用單選按鈕時(shí)無(wú)法更改innerHTML

汪汪一只貓 2021-12-23 10:38:13
我正在嘗試更改但目前當(dāng)我檢查其他單選按鈕時(shí)它目前沒(méi)有更改文本。我嘗試更改 HTML 輸入中的值,并搜索了 mozilla JS 幫助程序,但似乎找不到修復(fù)方法。let shapeChoice = document.querySelector('input[name="shape"]:checked').value;switch (shapeChoice) {  case 'circV':    document.getElementById("debug1").innerHTML = "Circle Area"    break;  case 'rectV':    document.getElementById("debug1").innerHTML = "Rectangle Area"    break;  case 'triV':    document.getElementById("debug1").innerHTML = "Triangle Area"    break;  case 'paraV':    document.getElementById("debug1").innerHTML = "Parallelogram Area"    break;  default:    doucment.getElementById("debug1").innerHTML = "Default"}<div id="radioHeader">  <input type="radio" name="shape" value="circV" onclick="" checked>  <label for="circleID">Circle</label>  <input type="radio" name="shape" value="rectV">  <label for="rectangleID">Rectangle</label>  <input type="radio" name="shape" value="triV">  <label for="triangleID">Triangle</label>  <input type="radio" name="shape" value="paraV">  <label for="parallelogramID">Parallelogram</label> <br>  <p id="debug1"></p></div>加載時(shí)“圓形區(qū)域”應(yīng)顯示在單選框下方,但在檢查其他單選框時(shí),它會(huì)更改為相應(yīng)形狀的 + 區(qū)域。但是,即使我選中另一個(gè)單選框,我也只會(huì)得到“圓形區(qū)域”。
查看完整描述

1 回答

?
鳳凰求蠱

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

您應(yīng)該附加一個(gè)onclick事件。當(dāng)事件發(fā)生時(shí),檢查所有情況。正如我在下面描述的那樣。


function radioClicked(){

  let shapeChoice = document.querySelector('input[name="shape"]:checked').value;


switch (shapeChoice) {

  case 'circV':

    document.getElementById("debug1").innerHTML = "Circle Area"

    break;


  case 'rectV':

    document.getElementById("debug1").innerHTML = "Rectangle Area"

    break;


  case 'triV':

    document.getElementById("debug1").innerHTML = "Triangle Area"

    break;


  case 'paraV':

    document.getElementById("debug1").innerHTML = "Parallelogram Area"

    break;


  default:

    doucment.getElementById("debug1").innerHTML = "Default"

}

};


radioClicked();

<div id="radioHeader" onload="radioClicked()" onclick="radioClicked()" >

    <input type="radio" name="shape" value="circV" onclick="" checked>

    <label for="circleID">Circle</label>

  

    <input type="radio" name="shape" value="rectV">

    <label for="rectangleID">Rectangle</label>

  

    <input type="radio" name="shape" value="triV">

    <label for="triangleID">Triangle</label>

  

    <input type="radio" name="shape" value="paraV">

    <label for="parallelogramID">Parallelogram</label> <br>

  

    <p id="debug1"></p>

  </div>


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

添加回答

舉報(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)