在页面加载时为 html 文档中所有文本区域的所有拼写错误的单词添加红色下划线

问题描述 投票:0回答:0

在页面加载时为 html 文档中所有文本区域的所有拼写错误的单词添加红色下划线。 我在 html 文档中有许多文本区域已经填充了文本。 我想使用默认拼写检查器为拼写错误的单词的所有文本区域添加下划线, 无需用户编辑每一个。

尝试了所有 chatgpt focus() 的东西。无用

<html>


<head>

   
  <meta charset="UTF-8">
  <title>Spellcheck Demo</title>
  <script>
    window.onload = function() {
      var textareas = document.getElementsByTagName("textarea");
      for (var i = 0; i < textareas.length; i++) {
        textareas[i].setAttribute("spellcheck", "true");
      }
    };
  </script>

</head>

<body>
  
  <textarea id="ta1"  >This is my txt</textarea>
  <textarea id="ta2" >This is colour</textarea>
  

</body>

</html>
html spell-checking
© www.soinside.com 2019 - 2024. All rights reserved.