我在iOS HTML5自动更正方面遇到了问题。它由JSBin http://jsbin.com/zusahev
复制// click - textarea loses focus - keyboard is closed
b1.addEventListener("click", function() {
t1.value = '';
});
// touchend with preventDefault to save textarea focus
// but iOS autocorrect doesn't update current word
// how to manually trigger autocorrect update?
b2.addEventListener("touchend", function(e) {
t2.value = '';
e.preventDefault();
});
答案 0 :(得分:0)
我的解决方案是让textarea失去焦点,然后再次关注它:http://output.jsbin.com/sihufuzigo
b2.addEventListener("click", function(e) {
t2.value = '';
t2.focus();
});
请注意,iOS以编程方式限制了focus()
字段的功能:它只能由真实用户触发的事件处理程序完成(在这种情况下是真正的“点击”事件) - 请参阅{{3} }了解更多信息