$(function() {
$("input").keypress(function(e) {
if (e.which == 13) {
var tbi =$(this).attr('tabIndex')
$('input').each(function(){
var dif = Number($(this).attr('tabIndex'))-Number(tbi);
if(dif==1){
this.focus();
this.select();
return false;
}
})
}
});
});
需要对页面元素指定tabIndex属性,且按顺序递加1
本文介绍了一种使用JavaScript实现的自定义Tab键导航功能,通过为页面元素设置tabIndex属性并按顺序递增,使得用户可以通过Tab键在不同输入框间进行切换。
188

被折叠的 条评论
为什么被折叠?



