使用向上/向下箭頭鍵在行中執行向上/向下移動使用此URL:Navigating through text input fields using arrow keys and return,它帶有代碼。
<script type="text/javascript">
$(document).ready(function(){
// get only input tags with class data-entry
textboxes = $("input.data-entry");
// now we check to see which browser is being used
if ($.browser.mozilla) {
$(textboxes).keypress (checkForAction);
}
else {
$(textboxes).keydown (checkForAction);
}
});
function checkForAction (event) {
if (event.keyCode == 13 || 40) {
currentBoxNumber = textboxes.index(this);
if (textboxes[currentBoxNumber + 1] != null) {
nextBox = textboxes[currentBoxNumber + 1]
nextBox.focus();
nextBox.select();
event.preventDefault();
return false;
}
}
}
</script>