Since the object obtained in JQuery is still a JQuery object, using focus() on it only makes the object obtain the onFocus() function, and cannot be the object to obtain focus. Therefore, in order to make the object obtain focus, the focus method of the DOM object should be called, that is:
The code copy is as follows:
$("#id")[0].focus();
Pay attention to the difference between two functions:
The code copy is as follows:
$("#id").focus();
$("#id")[0].focus();
The first is to increase the onFocus() time, and the other is to make the DOM object gain focus.