无为清净楼资源网 Design By www.qnjia.com
复制代码 代码如下:
//回车跳转
jQuery(document).ready(function () {
//$(':input:text:first').focus();
jQuery(':input:enabled').addClass('enterIndex');
// get only input tags with class data-entry
textboxes = jQuery('.enterIndex');
// now we check to see which browser is being used
if (jQuery.browser.mozilla) {
jQuery(textboxes).bind('keypress', CheckForEnter);
} else {
jQuery(textboxes).bind('keydown', CheckForEnter);
}
});

function SetControlEnterEvent() {
//$(':input:text:first').focus();
$(':input:enabled').addClass('enterIndex');
// get only input tags with class data-entry
textboxes = $('.enterIndex');
// now we check to see which browser is being used
if ($.browser.mozilla) {
$(textboxes).bind('keypress', CheckForEnter);
} else {
$(textboxes).bind('keydown', CheckForEnter);
}
}

function CheckForEnter(event) {
if (event.keyCode == 13 && $(this).attr('type') != 'button' && $(this).attr('type') != 'submit' && $(this).attr('type') != 'textarea' && $(this).attr('type') != 'reset') {
var i = $('.enterIndex').index($(this));
var n = $('.enterIndex').length;
if (i < n - 1) {
if ($(this).attr('type') != 'radio') {
NextDOM($('.enterIndex'), i);
}
else {
var last_radio = $('.enterIndex').index($('.enterIndex[type=radio][name=' + $(this).attr('name') + ']:last'));
NextDOM($('.enterIndex'), last_radio);
}
}
return false;
}
}
function NextDOM(myjQueryObjects, counter) {
if (myjQueryObjects.eq(counter + 1)[0].disabled) {
NextDOM(myjQueryObjects, counter + 1);
}
else {
myjQueryObjects.eq(counter + 1).trigger('focus');
}
}
标签:
JS,Enter键跳转,获得焦点

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com