haynar
haynar

Reputation: 6030

Preventing cycle through page elements using TAB

I have a requester div which is over of all my page and I want to prevent access to other elements of page using TAB while the dialog is opened. How can I do that?

Upvotes: 2

Views: 458

Answers (2)

Shawn Chin
Shawn Chin

Reputation: 86854

jQuery UI does that by binding to the keypress event for modal dialog boxes. When TAB is pressed, it manually handles the switching of focus between elements within the modal dialog only. The default behaviour is suppressed (return false) so focus is not switched to external elements.

Relevant source here: ui/jquery.ui.dialog.js

Upvotes: 1

Blazemonger
Blazemonger

Reputation: 92893

You can either set each element to be disabled, or set their tabindex to zero. Use jQuery to set $(selector).prop('disabled',true) or $(selector).attr('tabindex',0).

Upvotes: 2

Related Questions