[英]window.prompt stop working when adding function
var user = window.prompt("Welcome to the Vacation Planner. Please enter yourname");
document.getElementById("greeting").innerHTML += ", " + user;
var enterDays = document.getElementById("enterDays");
/*
function.calculateDays(){
var dayMessage = document.getElementById("dayMessage");
if(enterDays <4){
dayMessage.innerHTML = "Short trips are always worth it!";
}
else if(enterDays<7){
dayMessage.innerHTML = "Cool, you'll be there for a week"
}
else{
dayMessage.innerHTML = "You'll have plenty of time to relax and have fun!"
}
}*/
enterDays.onclick = calculateDays;
When I enter this code, the window.prompt work correctly. 当我输入此代码时,window.prompt可以正常工作。 But when I uncomment the function.calculateDays, the window.prompt stop working.
但是当我取消注释function.calculateDays时,window.prompt停止工作。 Can anybody explain why is it happening and how to solve it?
谁能解释为什么会这样以及如何解决呢? Thanks a lot!!!
非常感谢!!!
function.calculateDays
是无效的语法,并且会引发语法错误,该错误将阻止将来的代码调用,要对其进行修复,请用function calculateDays
替换它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.