每当我将一个to.LowerCase添加到else if语句时,它会导致整个语句不起作用。修复任何人?
document.getElementById("button").onclick=function() {
///monuments
var ask=document.getElementById("ask").value.toLowerCase(); ;
if (ask =="how tall are the pyramids") {
document.getElementById("spanId").innerHTML = "146.5 meters";
} else if (document.getElementById("ask").value == "how tall is the gateway arch") {
document.getElementById("spanId").innerHTML = "630 feet";
答案 0 :(得分:1)
分配后,您无需再次使用document.getElementById("ask").value
来询问
试试这个
var ask = document.getElementById("ask").value.toLowerCase();
var info = "";
if (ask == "how tall are the pyramids") {
info = "146.5 meters";
} else if (ask == "how tall is the gateway arch") {
info = "630 feet";
}
document.getElementById("spanId").innerHTML = info