我有3个用于输入电话号码的文本框。当用户键入时,它会自动从一个文本框移动到下一个文本框。当用户按backspace时,我可以将焦点移到上一个文本框。问题是,在IE中,焦点被设置到文本框的开头。下面是我的代码,它在chrome中运行得很好。
$('#AreaCode').live('keyup', function (event) {
if ($(this).val().length == $(this).attr("maxlength"))
$('#Prefix').focus();
});
$('#Prefix').live('keyup', function (event) {
if (event.keyCode == 8 && $(this).val().length == 0)
$('#AreaCode').focus();
if ($(this).val().length == $(this).attr("maxlength"))
$('#Number').focus();
});
$('#Number').live('keyup', function (event) {
if (event.keyCode == 8 && $(this).val().length == 0)
$('#Prefix').focus();
});
如何在后退时将焦点设置在内容末尾?
https://stackoverflow.com/questions/4609405
复制相似问题