?
?
?
?
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>switch輸出星期</title> </head> <body> <script type="text/javascript"> var week=new Date().getDay(); console.log(week); //0-6 switch(week){ case 0: document.write("今天是星期日"); break; //退出 case 1: document.write("今天是星期一"); break; case 2: document.write("今天是星期二"); break; case 3: document.write("今天是星期三"); break; case 4: document.write("今天是星期四"); break; case 5: document.write("今天是星期五"); break; default: document.write("今天是星期六"); break; } </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script> /*var age=35; if(age<18){ alert("您還沒有成年"); }*/ var age=prompt("請輸入您的年齡"); console.log(age); if(age<18){ alert("您還沒有成年"); }else{ alert("您已成年,請?zhí)峁┠纳矸葑C號"); } </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script> var password=prompt("請?jiān)O(shè)置您的密碼"); //判斷密碼的長度,如果不是6位,否則 if(password.length!=6){ alert("請輸入6位的數(shù)字密碼"); }else{ //如果密碼是非數(shù)字,否則是數(shù)字 if(isNaN(password)==true){ alert("密碼必須要是數(shù)字"); }else{ alert("密碼設(shè)置正確"); } } </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script type="text/javascript"> var str="abc123"; var num=parseInt(str); if(num==NaN){ //NaN和任何內(nèi)容都不相等,包括它本身 alert(NaN); }else if(num==123){ alert(123); }else if(typeof num=="number"){ alert("num"); }else{ alert("str"); } </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>for</title> </head> <body> <script type="text/javascript"> for(var i=1;i<=100;i++){ document.write(i+'<br/>'); //1 } for(var m=99;m>=1;m-=2){ console.log(m); //99 97 3 1 } alert(m); //-1 </script> </body> </html>
?
本文摘自 :https://www.cnblogs.com/