如何為 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>

更新於: 10-11-2023

2K+ 瀏覽量

開啟你的 職業生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.