var dialog = $('.modal');
dialog.on('keydown', function(e) {
var tab = 9;
if (e.which === tab) {
e.preventDefault();
var inputs = $('input, a, button', dialog).filter(':visible');
var ci = 0;
inputs.each(function(i) {
if ($(this)[0] == document.activeElement) {
ci = i;
}
});
var step = 1;
if (e.shiftKey) step = -1;
ci += step;
if (ci < 0) ci += inputs.length;
inputs[ci % inputs.length].focus();
}
});
108600cookie-checkjQuery: Enable Tab + Shift-tab only in modal dialog element