Add a keypress event on the last item to ignore the default tab action and return focus to the first item in the dialog box.
The following example assumes the last element is last_element_id and the first is first_element_id .
$('#last_element_id').on('keydown', function(e) { if ((e.keyCode || e.which) == 9) { $('#first_element_id').focus(); e.preventDefault(); } });
source share