Home >Web Front-end >JS Tutorial >Call the focus of the DOM object to give the text box focus_jquery

Call the focus of the DOM object to give the text box focus_jquery

WBOY
WBOYOriginal
2016-05-16 16:59:141085browse

Since the object obtained in JQuery is still a JQuery object, using focus() on it only causes the object to obtain the onFocus() function, not the object to obtain focus. Therefore, to enable the object to obtain focus, the focus method of the DOM object should be called, that is:

Copy code The code is as follows:

$("#id")[0].focus( ;

$("#id").focus();
$("#id")[0].focus();
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn