4

我有以下文本区域:

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

在使用此文本区域时,或者换句话说,当有人在键入时,我需要将 autocorrect 属性动态设置为 off 并重新设置为 on:

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

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

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

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

4

1 回答 1

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>

像这样的一些也许你需要

于 2013-06-05T20:53:28.083 回答