In firefox, if a textarea obtains the focus and the input method is activated, if js modifies the value of the textarea, The textarea will be cleared directly. The following is a specific solution, if a user encounters a similar problem, refer to the following in firefox, if a textarea gets the focus, when the input method is activated, such as the sogou input method, and the first Pinyin of a Chinese character is typed, if the background js changes the value of the textarea at this time, the textarea will be cleared directly,
In this state, if js modifies the textarea value, this bug is triggered,
How can this problem be solved?
After several attempts, we found that only when js modifies the value will the textarea lose the focus. After the modification, we can get the focus. This bug is also applicable to the input
The Code is as follows:
$ ("# Test"). blur ();
$ ("# Test"). val ('test ');
$ ("# Test"). focus ();