我有以下文本区域:
<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/