简体   繁体   中英

How to differentiate focus event between page-load and manual?

If anyone can come up with a better title, please edit.

I have a web form and the first field is a datepicker. I'm using jQuery-UI's datepicker, which means that whenever the textbox gets focus, the datepicker shows. Unfortunately, since this is the first element on the form, the textbox gets focus immediately on page load, and the datepicker opens without the user doing anything. Oh, and it also covers some other form fields that come next.

I could come up with a fix for this if I could only distinguish what caused that first focus event. Any ideas about it?

if I could only distinguish what caused that first focus event.

No you can't.

If tab-order is not important for your form just set tabIndex of datePicker's input to negative value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM