Home > Web Front-end > JS Tutorial > Example analysis of the method to focus the text box in JQuery_jquery

Example analysis of the method to focus the text box in JQuery_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:11:57
Original
1086 people have browsed it

This article analyzes the method of making a text box focus in JQuery. Share it with everyone for your reference. The specific analysis is as follows:

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:

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

It is important to note the difference between the two functions:

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

The first is to increase the onFocus() time, and the other is to make the DOM object gain focus.

I hope this article will be helpful to everyone’s jQuery programming.

Related labels:
Statement of this Website
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
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template