javascript - Keeping the tab focus inside a jQuery dialog -


i learning jquery dialog , use in side project. want add tabindex divs in dialog tabbing. focus goes elsewhere when tab on last element in dialog.

i want focus go first element when tab on last element. there way keep focus in dialog?

thanks!

add keypress event on last element ignore default tab action , put focus on first element in dialog.

the following example assumes last element last_element_id , first first_element_id.

$('#last_element_id').on('keydown', function(e) {     if ((e.keycode || e.which) == 9) {         $('#first_element_id').focus();             e.preventdefault();      }  }); 

Comments