<!-- 光标聚焦到文字的最后 -->
<script language="javascript">
var flag = true;
function onFocus(object) {
if (object.createTextRange) {
var range = object.createTextRange();
range.collapse(false);
range.select();
object.value=" ";
} else if (object.setSelectionRange) {
if (flag) {
setTimeout(function() { flag = false; object.focus(); }, 10);
object.blur();
object.addEventListener('blur', onBlur, false);
}
object.setSelectionRange(object.value.length, object.value.length);
}
}
function onBlur(object) {
flag = true;
this.removeEventListener('blur', onBlur, false);
}
</script>
js 光标聚焦到文字最后
最新推荐文章于 2024-01-26 20:24:09 发布