当前位置:Gxlcms > JavaScript > jQuery设置键盘切换文本框焦点

jQuery设置键盘切换文本框焦点

时间:2021-07-01 10:21:17 帮助过:1人阅读

这次给大家带来jQuery设置键盘切换文本框焦点,jQuery设置键盘切换文本框焦点的注意事项有哪些,下面就是实战案例,一起来看一下。

<script src="http://yige.org/static/js/j.js"></script>
jQuery(function () {
    jQuery('input:text:first').focus();//直接定位到当前页面的第一个文本框
    var $inp = jQuery('input:text');//所有文本框
    $inp.bind('keydown', function (e) {
        var key = e.which;
        if (key == 13) {
            e.preventDefault();
            var nxtIdx = $inp.index(this) + 1;
            jQuery(":input:text:eq(" + nxtIdx + ")").focus();
        }
    });
});

相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!

推荐阅读

怎么使用Mobile控制页面返回时get请求

Mobile框架中怎样使用表单组件

以上就是jQuery设置键盘切换文本框焦点的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行