jQuery to enable tab behavior when pressing enter
HTML
<table class="formGrid" >
<input id="input1" type="text" value="Press Enter to tab"><br/>
<input type="text" />
<a href="">link</a><br/>
<button>click</button><br/>
<textarea rows="10">Note:You need to press tab to get out of the textarea since it's a multi-line control</textarea> <br/>
<select>
<option value="1">One</option>
<option value="2">Two</option>
</select>
</table>
JavaScript
// Use to act like tab using enter key
$.fn.enterkeytab=function(){
$(this).on('keydown', 'input, select, a, button', function(e) {
debugger;
var self = $(this)
, form = self.parents()
, 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 {
next = focusable.eq(0);
next.focus();
//alert("wd");
//form.submit();
}
return false;
}
});
}
$("input1").enterkeytab(); // enter key tab