调用Javascript函数,但结果不完全返回

我是Meteor和Node.js的新手,因为我的问题可能仅仅是那些更熟练的人的平庸。

我正在编写一个脚本,将在未来30分钟内返回时间,格式如下: 11.12.16 20:05但是,如果我尝试运行我的函数,似乎没有任何事情发生,并且在控制台中没有错误或从服务器。

这是我的html:

 <body> <header>DPPZ</header> {{> price24}} {{> price32}} <div id="newWindow" style="display: none;"> <p id="time"></p> </div> </body> <template name="price24"> <div class="container24"> <button id="container24" onclick="ticket24()">24Kč</button> <p>(30 minut)</p> </div> </template> <template name="price32"> <div class="container32"> <button id="container32" onclick="ticket32()">32Kč</button> <p>(90 minut)</p> </div> </template> 

这是我的JS:

 function ticket24(){ document.getElementById("newWindow").style.display = "block"; var d = new Date(); var den = d.getDate(); var mesic = d.getMonth(); var rok = d.getFullYear(); var hodina = d.getUTCHours(); var minuta = d.getUTCMinutes(); switch(mesic){ case(0): mesic = 1; case(1): mesic = 2; case(2): mesic = 3; case(3): mesic = 4; case(4): mesic = 5; case(5): mesic = 6; case(6): mesic = 7; case(7): mesic = 8; case(8): mesic = 9; case(9): mesic = 10; case(10): mesic = 11; case(11): mesic = 12; } function novaMinuta(hodiny, minuty){ switch(minuta){ case(0): minuta = "00"; case(1): minuta = "01"; case(2): minuta = "02"; case(3): minuta = "03"; case(4): minuta = "04"; case(5): minuta = "05"; case(6): minuta = "06"; case(7): minuta = "07"; case(8): minuta = "08"; case(9): minuta = "09"; default: minuta = minuta; } if (10 <= Number(minuta) >= 29){ return Number(hodina + 1)+ ":" + Number(minuta) + 30; } else if (Number(minuta) == 30){ return Number(hodina + 2) + ":" + "00"; } else if (Number(minuta) > 30){ return Number(hodina + 2) + ":" + Number(minuta) - 30; } } rok = rok.toString().replace("20", ""); document.getElementById("time").innerHTML = den + "." + mesic + "." + rok + " " + novaMinuta(hodina, minuta); document.getElementById("newWindow").style.display = "block"; } 

document.getElementById("newWindow").style.display = "block"; 工作,但代码的其余部分“打印”什么。

你忘了每个casebreak时间:

 switch(mesic){ case(0): mesic = 1; break; case(1): mesic = 2; break; ...