嗨,我有这个 JS 代码
function myFunction() {
var g;
var d = new Date().getDay(); switch (d) { case 0: g = "Today it's Sunday"; break; case 1: g = "Today it's Monday"; break; case 2: g = "Today it's Tuesday"; break; case 3: g = "Today it's Wednesday"; break; case 4: g = "Today it's Thursday"; break; case 5: g = "Today it's Friday"; break; case 6: g = "Today it's Saturday"; break; default: x = "Looking forward to the Weekend"; } var y; //popup var name = prompt("Please enter your name", " (your name is here)"); if (name != null) { y = 'How are you today?'; document.getElementById("popup").innerHTML = y; // } var x = ""; //שעה var time = new Date().getHours(); if (time < 12) //תנאי { x = "Have a beautiful morning " + name + '! '; } else if (time < 16) { x = "Great noon! Enjoy this day " + name + '!'; } else if (time < 19) { x = "Great afternoon! Enjoy them " + name + '!'; } else if (time < 23) { x = "Good evening! have some fun and take some rest befor the day over" + name + '!'; } document.getElementById("demo").innerText = x + "<br/>" + g; }
为什么我把 br 标签放在它只是在屏幕上写了 br 标签,而现在行之间有中断?我还尝试输入“\n”,但它也不起作用。为什么?