您现在的位置:首页 --> JavaScript --> jquery实现的回车(Enter)替换为Tab键
jquery实现的回车(Enter)替换为Tab键
浏览:3201次 出处信息
$(document).ready(function () {
$(':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');
}
}
$(':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');
}
}
建议继续学习:
- JQuery实现Excel表格呈现 (阅读:46566)
- 分享一个JQUERY颜色选择插件 (阅读:12782)
- jQuery插件---轻量级的弹出窗口wBox. (阅读:9732)
- 10个强大的Ajax jQuery文件上传程序 (阅读:7807)
- jQuery的data()方法 (阅读:7689)
- jQuery性能优化指南 (阅读:7444)
- jQuery Color Animations颜色动画插件 (阅读:7202)
- 精于图片处理的10款jQuery插件 (阅读:6349)
- jQuery中getJSON跨域原理详解 (阅读:5678)
- 配合jquery实现异步加载页面元素 (阅读:5428)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
扫一扫订阅我的微信号:IT技术博客大学习
<< 前一篇:Jquery通用表单验证类
后一篇:前端要给力之:原子,与原子联结的友类、友函数 >>
文章信息
- 作者:废墟 <a@anerg.cn> 来源: 废墟
- 标签: jquery Tab 回车
- 发布时间:2011-09-19 23:42:51
建议继续学习
近3天十大热文
-
[70] Java开发岗位面试题归类汇总
-
[67] Go Reflect 性能
-
[64] 如何拿下简短的域名
-
[63] IOS安全–浅谈关于IOS加固的几种方法
-
[61] 【社会化设计】自我(self)部分――欢迎区
-
[61] Oracle MTS模式下 进程地址与会话信
-
[61] android 开发入门
-
[50] 图书馆的世界纪录
-
[50] WEB系统需要关注的一些点
-
[47] Twitter/微博客的学习摘要