【问题标题】:Adjust attribute of html textarea dynamically?动态调整html textarea的属性?
【发布时间】:2013-06-01 15:44:07
【问题描述】:

我有以下文本区域:

<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 中,如果可能的话也可以尝试在本地执行此操作,但这是首先想到的。这可能吗?

【问题讨论】:

    标签: html ios uiwebview textarea autocorrect


    【解决方案1】:
    <!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>
    

    也许你需要这样的一些

    【讨论】:

    • 使用 'focus' 和 'blur' 肯定会起作用,但我正在尝试在键盘绝对不应该上下跳跃的 ios 设备上完成此操作......不幸的是。
    猜你喜欢
    • 1970-01-01
    • 2013-06-21
    • 1970-01-01
    • 2012-11-19
    • 1970-01-01
    • 1970-01-01
    • 2021-11-26
    • 1970-01-01
    • 2020-07-25
    相关资源
    最近更新 更多