Thursday, January 3, 2019

Enter Key Press Change Focus to Next Item like a Tab

$('body').on('keydown', 'input, select, textarea', function(e) {
    var self = $(this)
      , form = self.parents('form:eq(0)')
      , focusable
      , next
      ;
    if (e.keyCode == 13) {
        focusable = form.find('input,a,select,button,textarea').filter(':visible');
        next = focusable.eq(focusable.index(this)+1);
        if (next.length) {
            next.focus();
        } else {
            form.submit();
        }
        return false;
    }
});

No comments:

Post a Comment

Horizontal Scaling vs Vertical Scaling

 একটা application হঠাৎ করে অনেক বেশি user পেতে শুরু করল। আগে যেখানে ১,০০০ জন user ছিল, এখন সেখানে ১ লাখ user! তখন স্বাভাবিকভাবেই প্রশ্ন আসে—...