Search code examples
javascriptpopupwindowtabindex

tabIndex and Javascript popup window


I have few element in my html page which has tabIndex attribute.

Now I have a div based modal popup window opening from this page. I have few elements in this popup window which has tabIndex.

Problem: When the user presses the tab, the focus is set to each elements in the popup window, after the last element in the popup got focus and still the user press tab the focus is going to the elements in the main page which I dont want.

Is there any way to rotate the focus on elements in the popup window itself?


Solution

  • If all you need is to refocus on the first element after the last element focus is out then use Jquery's focustout() for last element and then use $('#FirstElement').focus()

    I hope that helps