动态调整html textarea的属性?

时间:2013-06-05 19:40:46

标签: html ios uiwebview textarea autocorrect

我有以下textarea:

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

1 个答案:

答案 0 :(得分: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>

有些人可能需要