Javascript IF语句
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Javascript IF语句相关的知识,希望对你有一定的参考价值。
<html> <head> var secret_password = "jasmine"; var entered_password = prompt("please enter password", " "); if (entered_password != secret_password) { document.write("incorrect"); } else { document.write("welcome"); } </script> </head> <body> </body> </html> <html> <head> <script language="javascript"> var secret_password = "jasmine"; var usernmae = "password"; var entered_password = prompt("please enter password", " "); var entered_username = prompt("please enter username", " "); if ((entered_password == secret_password) && (entered_username == username)) { document.write("correct"); } else { document.write("try again"); } </script> </head> <body> </body> </html> <html> <head> <script language="javascript"> var admin = admin var developer = "mike"; var user = "user"; var entered_password = prompt("please enter password", " "); switch (entered_password) { case "admin": alert("you are admin"); break case "mike": alert("you are a developer"); break case "user": alert("you are a user"); break default: alert("password Incorrect!!"); break } </script> </head> <body> </body> </html>
以上是关于Javascript IF语句的主要内容,如果未能解决你的问题,请参考以下文章
JavaScript学习——JavaScript 条件 语句 switch语句 while语句