This time I will bring you jQuerySet the keyboard to switch the focus of the text box. What are the precautions for jQuery to set the keyboard to switch the focus of the text box. The following is a practical case. Let’s take a look. one time.
<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(); } }); });
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website Other related articles!
Recommended reading
How to use Mobile to control the get request when the page returns
How to use the form component in the Mobile framework
The above is the detailed content of jQuery sets keyboard to switch text box focus. For more information, please follow other related articles on the PHP Chinese website!