在表單必填項之前加上提示
阿新 • • 發佈:2019-01-04
表單必填項之前加入紅色的*符號
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="bootstrap.min.css"> <title>Personal Portfolio</title> <style> </style> </head> <body> <div class="container"> <form role="form"> <div class="form-group"> <label for="name">姓名</label> <input id="name" type="text" class="form-control" placeholder="請輸入使用者名稱" required> </div> <div class="form-group"> <label for="pwd">密碼</label> <input id="pwd" type="password" class="form-control" required> </div> <button type="submit">提交</button> </form> </div> <!-- 載入第三方js庫 -->
<script src="jquery.min.js"></script>
<script src="bootstrap.min.js"></script> <!-- 自定義javascript --> <script> $('input[required]').before('<span style="color:red">*</span>'); </script></body></html>