Foundation - 幫助文字



說明

幫助文字用於向用戶傳達元素的目的,通常放置在欄位下方。向其提供一個唯一 ID,並向輸入新增 aria-describedby 屬性。

示例

以下示例演示了 Foundation 中的 幫助文字

<html>
   <head>
      <title>Form Help Text</title>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/css/foundation.min.css" crossorigin="anonymous">

      <!-- Compressed JavaScript -->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" crossorigin="anonymous"></script>

   </head>

   <body>
      <label>Choose a Password
         <input type = "password" aria-describedby = "pwdHelpText">
      </label>

      <p class = "help-text" id = "pwdHelpText">Password should be at least 8
      characters and must include atleast one digit and a special character.</p>

      
      <script>
         $(document).ready(function() {
            $(document).foundation();
         })
      </script>
   </body>
</html>

輸出

讓我們執行以下步驟來了解上面給出的程式碼是如何工作的 −

  • 儲存上面給出的 html 程式碼 form_help_text.html 檔案。

  • 在瀏覽器中開啟此 HTML 檔案,將顯示如下輸出。

foundation_forms.htm
廣告