/*开启表格编辑方向键导航方向键(←): VK_LEFT (37)方向键(↑): VK_UP (38)方向键(→): VK_RIGHT (39)方向键(↓): VK_DOWN (40)*/function OpenTableEditKeyNavigation() {$(document).on("keyup", "tr.editable-select input", function (event) {var keyCode = event.keyCode;var $this = $(this);switch (keyCode) {case 37://向左case 39://向右var $trInputs = $this.parents("tr.editable-select").find("input[type!='hidden']");var curInputIndex = $trInputs.index($this);var nextIndex = keyCode == 37 ? (curInputIndex - 1) : (curInputIndex + 1);if (nextIndex===-1) {nextIndex = $trInputs.length - 1;}else if (nextIndex === $trInputs.length) {nextIndex = 0;}$trInputs[nextIndex].focus();break;case 38://向上case 40://向下var $curTr = $this.parents("tr.editable-select");var $trs = $curTr.parents("tbody").find("tr");var $trInputs = $curTr.find("input[type!='hidden']");var curInputIndex = $trInputs.index($this);var curTrIndex = $curTr.index();var nextIndex = keyCode === 38 ? (curTrIndex - 1) : (curTrIndex + 1);if (nextIndex === -1) {nextIndex = $trs.length - 1;}else if (nextIndex === $trs.length) {nextIndex = 0;}var nextTr = $trs[nextIndex];if (nextTr) {nextTr.click();$(nextTr).find("input")[curInputIndex].focus();}break;default:}});}
700字范文,内容丰富有趣,生活中的好帮手!