如何在 HTML 中為文字新增拼寫檢查器?


要新增拼寫檢查器,請在 HTML 中使用 spellcheck 屬性。該屬性檢查輸入元素中的文字拼寫和語法,<textarea> 元素 和可編輯元素。

新增拼寫檢查

在文字型別標籤內寫入 spellcheck="true"

<input type="text" name="sub" spellcheck="true">    

注意 − 它適用於輸入元素,但不適用於密碼。

示例

您可以嘗試執行以下程式碼以在 HTML 中新增拼寫檢查器 −

<!DOCTYPE html>
<html>
   <body>
      Subject: <input type="text" name="sub" spellcheck="true">
      <p>Add an incorrect spelling for a word above and see what happens.</p>
      <p contenteditable="true" spellcheck="true">This is an editable conttent, with a spelling mistake. Click to edit.</p>
   </body>
</html>

更新於: 2023-11-10

2K+ 瀏覽

開啟你的事業

完成課程以獲得認證

開始
廣告
© . All rights reserved.