2013-06-05 36 views
4

我有以下的textarea:動態調整html 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 UIW ebView,如果可能的話,也可以嘗試在本地執行此操作,但這是首先想到的。這可能嗎?

回答

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> 

一些這樣也許你需要

+0

使用「焦點」和「模糊」肯定會工作,但我試圖做到這一點在iOS設備上,其中的鍵盤絕對不能跳起來不幸的是... – Karoh