问题
I have an <input type="text">
element. The user types a string and hits enter which clears the element via $('input').val('')
. The problem apparently is that iOS still has the previous input string in its autocorrect buffer, so when you begin to type a new word and hit space, it sees the last word from the previous string and the first word from the new string as one 'word' and attempts to autocorrect it. Example:
message1: hello there
message2: well hi neighbor
iOS sees: therewell
on messages2 and autocorrects to wellthere well
another example:
message1: hello moto
message2: boat
autocorrects to boatmotorboat
where motorboat
is the autocorrected version of motoboat
(combination of moto
from the first message and boat
from the second.
I realize this may just be a bug in mobile safari and I should just disable autocorrect on the input but perhaps there is a better solution?
来源:https://stackoverflow.com/questions/18689842/clearing-input-element-in-mobile-safari-with-javascript-does-not-clear-the-ios-a