bootstrap 表单重置
<!doctype html> <html lang="zh-CN"> <head> <link rel="icon" href="/static/image/favicon.ico"> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content=""> <meta name="author" content=""> <title>xxx系统</title> <!-- Bootstrap core CSS --> <link href="/static/css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="/static/signin/signin.css" rel="stylesheet"> <script src="/static/jq/jquery-3.6.0.min.js"></script> <script src="/static/js/bootstrap.min.js"></script> <style type="text/css"> body { background-image:url(/static/image/d.jpg); background-repeat: no-repeat; background-attachment: fixed; background-size: 100% 100%; color:black; } </style> </head> <body> <div class="container"> <form class="form-signin" action="/login/" method="POST"> <h2 class="form-signin-heading text-center">xxx系统</h2> <br> <!-- 下拉选则地区 --> <p> <label for="diqu">请选择地区</label> <select name="selectdq" class="form-control form-control-placeholder" required="required"> <option value="bj" style="color: black;">北京</option> <option value="hz" style="color: black;">杭州</option> </select> </p> <label for="inputUsername">用户名</label> <input type="text" id="inputUsername" name="username" class="form-control" placeholder="用户名" required autofocus style="margin-bottom: 5px;"> <label for="inputPassword">密码</label> <input type="password" id="inputPassword" name="password" class="form-control" placeholder="密码" required> <div> <label class="col-md-4"> <input type="checkbox" value="remember-me"> 记住我 </label> <label class="col-md-3 col-md-offset-5"> <button class="btn btn-sm btn-default" id="resetBtn">重置</button> </label> </div> <button class="btn btn-lg btn-success btn-block" type="submit">登录</button> <!-- <a href="#" class="col-md-4 text-danger"><strong>忘记密码</strong></a> <a href="#" class="col-md-3 col-md-offset-5 text-danger"><strong>注册</strong></a> --> {{ error }}<br> {% csrf_token %} </form> </div> <!-- /container --> <script> $(document).ready(function(){ $("#resetBtn").off().on("click", function () { $("#inputUsername").val(""); $("#inputPassword").val(""); }) }); </script> </body> </html>