如這個(gè)登錄驗(yàn)證的例子,兩個(gè)if嵌套在一起是怎么運(yùn)行的?<!DOCTYPE html><html><head> <title>login</title> <meta charset="utf-8"></head><body> <form id="loginform" name='loginform' onsubmit="return checkLogin()"> <div> <label for="username">賬號:</label> <input type="text" id="username" name="username"> </div> <div> <label for="password">密碼:</label> <input type="password" id="password" name="password"> </div> <input type="submit" value="登錄"> </form> <script type="text/javascript"> //驗(yàn)證登錄 function checkLogin() { if (loginform.username.value != "") { if (loginform.password.value != "") { return ture } else { alert('密碼不能為空'); return false } } else { alert('用戶名不能為空'); return false } } </script></body></html>
js兩個(gè)if嵌套在一起是如何運(yùn)行的?
素胚勾勒不出你
2019-02-12 17:19:12