资讯王 发表于 2011-4-8 15:30:06

Javascript 使用focus 设置文本框焦点

Javascript 使用focus 设置文本框焦点
The javascript code below shows how to set the focus on an Input Field / Form Field / Html Element (Textbox) when the page is loaded.<html>
<head>
<script type="text/javascript">
function setFocus()
{
   document.getElementById("name").focus();
}
</script>
</head>

<body onload="setFocus()">
<form>
       Name: <input type="text" id="name" size="30"><br />
       Surname: <input type="text" id="surname" size="30">
</form>
</body>

</html>
页: [1]
查看完整版本: Javascript 使用focus 设置文本框焦点