Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery blur but keep tab position

Tags:

jquery

I have a bunch of input fields on a page that need to work for people who just use their keyboard to tab through and fill everything out.

One of those text fields does some extra work when certain text is entered into it. At the end of that work I want the focus to be taken off of that input field. I've used $(this).blur(); to take off the focus.

The problem is then that after that, when you press tab on your keyboard you start at the beginning of the page. How do I blur but keep the tab position on the page?

NOTE: I can not use any type of:

     $(this).next().focus();

because the next input could potentially be another type of input that initiates something else when being focused on. So I don't want the user to experience that something else until they have actively selected/tabbed to it.

Here's a jfiddle example of what I'm talking about: http://jsfiddle.net/DqVvf/1/

Try clicking on the first input, entering something, pressing tab to go to the "zip" field, then press the zero key on your keyboard. That triggers the blur. Then press tab again and you're taken back to the first input on the page.

like image 838
rgbflawed Avatar asked Feb 05 '26 08:02

rgbflawed


1 Answers

Maybe you could put an invisible input (display:none or similar) between zip and somethingElse, and focus that instead of just blurring zip? Then when the user presses tab, it would move to somethingElse.

like image 91
eliah Avatar answered Feb 07 '26 01:02

eliah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!