//按键监听事件 $(document).on('keydown', '.layui-input', function(event) { var td = $(this).parent('td'); var index = td.index(); var tr = td.parent('tr'); var key = event.keyCode; switch (key) { case 38://上键ArrowUp tr['prev']().children('td').eq(index).click(); setTimeout(function(){ $('.layui-table-edit').select(),0 }); break; case 40://下键ArrowDown tr['next']().children('td').eq(index).click(); setTimeout(function(){ $('.layui-table-edit').select(),0 }); break; case 9://TAB tr['next']().children('td').eq(index).click(); setTimeout(function(){ $('.layui-table-edit').select(),0 }); break; case 13://回车 tr['next']().children('td').eq(index).click(); setTimeout(function(){ $('.layui-table-edit').select(),0 }); break; case 37://左键ArrowLeft td['prevAll']('[data-edit="text"]:first').click(); break; case 39://右键ArrowRight td['nextAll']('[data-edit="text"]:first').click(); break; } });
标签:index,layui,tr,table,td,上下左右,click From: https://www.cnblogs.com/iamwhy/p/17727262.html