html - 动态调整html textarea的属性?

标签 html ios uiwebview textarea autocorrect

我有以下文本区域:

<textarea id="edit-note-text" autocorrect="on"><%= text %></textarea>

当这个文本区域正在使用时,或者换句话说,当有人在输入时,我需要动态地将自动更正属性设置为关闭并重新打开:

<textarea id="edit-note-text" autocorrect="off"><%= text %></textarea>

不幸的是,这似乎不起作用:

document.getElementById(‘textarea’).setAttribute(‘autocorrect’, ‘off’);

我在 iOS UIWebView 中,如果可能的话也可以尝试在本地执行此操作,但这是我首先想到的。这可能吗?

最佳答案

<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
    <title>Document</title>
    <script>
        //Declare functions
            function taFocus(element){ element.setAttribute("autocorrect", "off")}
            function taBlur(element){ element.setAttribute("autocorrect", "on")}    
    </script>
    </head>
    <body>
    <textarea id="edit-note-text" autocorrect="on" onfocus="taFocus(this);" onblur="taBlur(this);" >texto</textarea>
    <textarea id="edit-note-text2" autocorrect="on">texto</textarea>
    </body>
</html>

也许你需要这样的东西

关于html - 动态调整html textarea的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16948439/

相关文章:

html - Canvas 不使用HTML5绘制带有音频标签的图形

html - 使用 CSS 居中文本

html - 如何在静态文件夹外的django中使用静态内容

iOS - 使用容器 View 时如何避免将导航控件放在导航栏项目中

ios - 更改状态栏颜色

ios - Facebook SDK 3.1 登录错误

javascript 程序在 codepen 中有效,但在我尝试过的任何浏览器中都无效

ios - 如何更改 UIWebView 中的 src 值?

ios - 在 UIWebView 中查看 PDF

ios - UIWebView 返回特定页面