我有一个前面的问题,但我得到它现在我有一个新的问题下面是代码。Javascript天气计划
<!DOCTYPE html>
<html lang="en">
<title>Weather</title>
<head>
<script>
\t
\t var temp = prompt("Enter the temp from outside");
\t var sky = prompt("tell us what it is like outside put ether sun, rain, snow (it is case sensitive so follow orders.)");
\t function getHot(temp) {
\t \t if (temp >= 100) {
\t \t document.write ("Bet u wish you could go naked but shorts and T-shirt will do.");
\t \t }
\t \t else if (temp >= 60) {
\t \t document.write ("Ok thats a bit better but i would say shorts and T-shirt would be good.")
\t \t }
\t \t else if (temp >= 40){
\t \t document.write ("Getting a bit nippy out maybe get some pants and a jacket.")
\t \t }
\t \t else if (temp >= 0){
\t \t document.write ("Sucks to be you right now put on you big boy pants get a sweater and put a heavy coat on.")
\t \t }
\t \t else if (temp <= -1){
\t \t document.write ("Stay inside you fool theres no need to freeze to death.")
\t \t }
\t \t else {
\t \t document.write ("you mess with me i mess with you refresh to do this right.")
\t \t }
\t \t }
\t function getLight(sky) {
\t if (sky = sun){
\t document.write ("Enjoy the light get out your house it's good for you inless it's to hot or to cold then hide from the light.")
\t }
\t else if (sky = rain){
\t document.write ("Can't beleave you have to ask this but get a umbrella and maybe a poncho.")
\t }
\t else if (sky = snow){
\t document.write ("If you are afraid of getting wet then use a umbrella other then that bundle up.")
\t }
\t else {
\t document.write ("not going to tell you again follow what i say refresh and do it again.")
\t }
\t }
\t
\t getHot(temp);
\t getLight(sky);
\t
</script>
</head>
</html>
确定,所以它会提示输入2个输入用户但随后只显示用于临时输入信息,我需要它同时显示任何建议?
不要使用'document.write',请参阅[规范(http://www.w3.org/警告TR/HTML5/dom.html#文件撰写%28%29)。改用DOM方法。 – Oriol 2015-02-07 00:01:04
您能否详细说明我们还没有在我的课程中介绍DOM? – 2015-02-07 00:03:23
'sky = snow'应该是'sky == snow'' – 2015-02-07 00:06:07