[英]probably an easy fix but cant fix myself
anyone know what I'm doing wrong with this, id like to make a welcome message that displays on startup which asks you your name and then welcomes you with a greeting dependent on the current time.任何人都知道我做错了什么,我喜欢在启动时显示一条欢迎消息,询问您的姓名,然后根据当前时间用问候语欢迎您。
The issue I'm having is that the prompt will work if everything else is comment blocked but also won't display on to the page in white text我遇到的问题是,如果其他所有内容都被评论阻止,提示将起作用,但也不会以白色文本显示在页面上
var name
name = prompt("Please enter your name.");
document.getElementById("demo").innerHTML = (msg);
msg.style.color = 'White';
var now = Date();
var hrs = now.getHours();
var msg = "";
if (hrs > 6) msg = "Good morning";
if (hrs > 12) msg = "Good afternoon";
if (hrs > 17) msg = "Good evening";
var now = new Date();
var now = new Date();
创建var now = new Date();
var name = prompt("Please enter your name.");
var msg = "";
console.log(name);
document.getElementById("demo").style.color = 'red'; // use other color because white is default background color and your text will not be visible
var now = new Date();
var hrs = now.getHours();
console.log(hrs);
if (hrs > 0)
msg = "Good early morning "+ name;
else if (hrs > 6)
msg = "Good morning "+ name;
else if (hrs > 12)
msg = "Good afternoon "+ name;
else if (hrs > 17)
msg = "Good evening "+ name;
console.log(msg);
document.getElementById("demo").innerHTML = msg;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.