0

I am using following code to tab through form elements using enter key. Problem is that this code skip select2 elements.

        $('body').on('keydown', 'input, select', function(e) {
            if (e.key === "Enter") {
                var self = $(this), form = self.parents('form:eq(0)'), focusable, next;
                focusable = form.find('input,a,select,button,textarea').filter(':not([disabled]):not([tabindex="-1"]):visible');
                next = focusable.eq(focusable.index(this)+1);
                if (next.length) {
                    next.focus();
                } else {
                    //form.submit();
                }
                return false;
            }
        });
freedomn-m
  • 27,664
  • 8
  • 35
  • 57
  • Can u create JSFiddle ? – mr. pc_coder Apr 05 '20 at 12:13
  • What select2 version are you using for testing? – palaѕн Apr 05 '20 at 12:31
  • select2 will not keep `` tag the cursor focus happens to the next select2 element, from there it is not jumping to next, there is already a keypress handled in select2
  • – Dickens A S Apr 05 '20 at 12:40