Js小辣鸡

文献种类:专题技术
开发工具与关键技术: Dw与js
作者:吴新洋

<body>
    <p id="demo">放假v/s不放假</p>
<button onclick="myFunction()">今天</button>
</body>
<script>
function myFunction()
{
var day="";
var time=new Date().getDay();
if (time<6)
  {
      day="好好学习 天天向上";
  }
else
  {
      day = "let’s   play  computer game";
  }
document.getElementById("demo").innerHTML=day;
}
 </script>



2.Do while 
var time = new Date()
do
{
document.write(""+time.getHours())
if(19.5<time<21.5){
	document.write("<br />")
	document.write("还没放学快敲代码")
	
}else{
    document.write("自由时间")
}
}
while ( time<23)


3获取当前时间:

<script type="text/javascript">
var time = new Date()
var hello=new Date().getMonth()
document.write("现在是北京时间:")
document.write(time.getFullYear())
document.write("年")
document.write(hello+1)	 			   			  
document.write("月")
document.write(time.getDate()) 
document.write("日")
document.write(time.getHours())
document.write("时")
document.write(time.getMinutes())
document.write("分")
document.write(time.getSeconds())
document.write("秒")
</script>

猜你喜欢

转载自blog.csdn.net/qq_44254122/article/details/86546486