[英]Tab key not working properly
I have made a key with value=tab when clicking on tab it changes the focus to next textbox its fine up till here but suppose i focus on second textbox and then press 1 key from the keypad made in webpage.after that if i press the tab key again it focus on first textbox whereas it should focus on third textbox. 我在选项卡上单击时用value = tab键创建了一个键,它将焦点更改为下一个文本框,直到现在为止,但是假设我将焦点放在第二个文本框上,然后从网页中的键盘上按1键。之后,如果按再按一次Tab键,它将焦点放在第一个文本框上,而应将焦点放在第三个文本框上。
$txt[0].setSelectionRange(pos+1, pos+1);
});
$('.delete').on('click',function() {
var $myInput = $txt;
$myInput.val($myInput.val().slice(0, -1));
});
$('.clear').on('click',function() {
$txt.val('');
});
Just right: 正好:
$txt.focus();
inside: 内:
$(".num").on("click", function(e) {
if (! $txt) return false; // If tracker is cleared, just return
var prev = $txt.val();
var num = this.value;
var pos = $txt[0].selectionStart;
var newValue = prev.substring(0, pos) + num + prev.substring(pos);
$txt.val(newValue);
$txt[0].setSelectionRange(pos+1, pos+1);
$txt.focus();
});
You will get the correct focus. 您将获得正确的焦点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.