一、JavaScript条件语句
1.if...else
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script> var i=11; if (i==10){ document.write("yeleven"); }else{ document.write("yeleven2"); } </script> </body> </html>
2.switch
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script> var i=5; switch(i){ case 1: document.write("i=1"); break; case 2: document.write("i=2"); break; default: document.write("条件不满足case"); break; } </script> </body> </html>
原文地址:http://11317783.blog.51cto.com/11307783/1791880