输入框内输入文字后,光标和文字之间,留有一点空隙,使用js方法,给框内的最后文字加个空格;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<script>
function a()
{
var a = window.document.getElementById("aa").value;
window.document.getElementById("aa").value = a.replace(" ", ") + " ";
var e = event.srcElement;
var r = e.createTextRange();
if(a.length == 1)
{
r.moveStart('character',1); //定位光标位置
r.collapse(true);
r.select();
}
else
{
r.moveStart('character',a.length - 1); //定位光标位置
r.collapse(true);
r.select();
}
}
</script>
</HEAD>
<BODY>
<input id=aa onkeyup="a()" />
</BODY>
</HTML>