<!DoctypeHTMLPUBLIC"-//W3c//DTDHtml1.0Transitional//EN">
<html>
<head>
<title>文本框宽度自动适应文本宽度</title>
</head>
<scripttype="text/javascript">
functionchangeInputlength(cursor)
{
vargetcount=document.getElementById("countFont");
vargetText=document.getElementById("text");
getcount.innerHTML='<font>第'+(parseInt(getText.value.length)+1)+'个字符</font>';
cursor.size=getText.value.length+2;
}
</script>
<body>
请输入字符:<inputtype="text"size="3"id="text"onkeydown="changeInputlength(this);"/>
<spanid="countFont"></span>
</body>
</html>
|