10
在文本框中将焦点设置在最后一个字符之后
我有3个用于输入电话号码的文本框。当用户键入内容时,它会自动从一个文本框移动到下一个文本框。当用户按下退格键时,我可以将焦点移到上一个文本框。问题在于,在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(); }); 向后移动时如何将焦点设置在内容的末尾?