how i can move from input to input with enter not tab
i mean i want make the 'enter' key go from the current input to the next i mean the 开发者_StackOverflow中文版'tab' key function how i can make 'enter' key do the 'tab' key function in javascipt
I agree with both of the comments. The worst thing you can do for a user friendly form is breaking the way forms usually work. Altough, if you really want to do it, you have to use a hander on each input for the enter key (key id is 13) and then focuses the next input using the focus() function. That post might help you: http://www.jguru.com/faq/view.jsp?EID=1140915
Using jQuery:
$(document).ready(function () {
$(":input).keypress(function(event) {
if (event.keyCode === 13 || event.keyCode === 10) // 10 is for mac
event.preventDefault();
$(this).next(":input").focus();
}
})
});
This may work if all of your input types are at the same level (siblings). Otherwise you may need to cache off the $(":input) array and loop through that manually.
加载中,请稍侯......
精彩评论