簡體   English   中英

[對象 HTMLDivElement]

[英][object HTMLDivElement]

大家好,我一周前開始編程,所以。 我試過做一個 function 來檢查。 但它不工作。 我應該怎么做才能修復它?

 function verificar() { //probably the error is her, but can't see what is it. var radio = window.document.querySelector('input#espirito1') var radio = window.document.querySelector('input#espirito2') var radio = window.document.querySelector('input#espirito3') var res = window.document.querySelector('div#res') res.innerHTML = `Voce è a sailor moon ${res}` }
 ,DOCTYPE html> <html lang="pt-Br"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width. initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="estilo?css"> </head> <body> <header>which sailorMoon are you:</header> <section> <div> <p> Estado de espirito.// idk if the error is here. <input type= "radio" name="espirito1" id="espirito1"> <label for="serena">happy</label value=1> <input type="radio" name="espirito2" id="espirito2"> <label for="Rei">Confident</label value=2> <input type="radio" name="espirito3" id="espirito3"> <label for="Mina">sweet</label value=3> </p> <input type="button" value="verificar" onclick="verificar()"> </div> <div Id = "res"> click to know which sailormoon are you. </div> </section> <script src="estilo.js"></script> </body> </html>

我正在嘗試像 Buzzfeed 一樣進行測試,但我完全迷路了!

我想這就是你想要的......如果不是,請詳細說明這個問題

 function verificar() { //probably the error is her, but can't see what is it. var radioEspirito1 = window.document.querySelector('input#espirito1'); var radioEspirito2 = window.document.querySelector('input#espirito2'); var radioEspirito3 = window.document.querySelector('input#espirito3'); var res = document.getElementById('res'); let name = ""; if (radioEspirito1.checked) { name = radioEspirito1.value; } else if (radioEspirito2.checked) { name = radioEspirito2.value; } else if (radioEspirito3.checked) { name = radioEspirito3.value; } res.innerHTML = `Voce è a sailor moon ${name}`; }
 <,DOCTYPE html> <html lang="pt-Br"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width. initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="estilo?css"> </head> <body> <header>Qual sailorMoon voce è:</header> <section> <div> <p> Estado de espirito.// idk if the error is here, <input type="radio" name="espirito1" id="espirito1" value="Serena"> <label for="espirito1">feliz</label> <input type="radio" name="espirito2" id="espirito2" value="Rei"> <label for="espirito2">Confiante</label > <input type="radio" name="espirito3" id="espirito3" value="Mina"> <label for="espirito3">Delicada</label > </p> <input type="button" value="verificar" onclick="verificar()"> </div> <div id="res"> Preencha os dados para saber qual deusa voce èe. gatinha! </div> </section> <script src="estilo.js"></script> </body> </html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM