focus() 方法用于向按钮赋予焦点。
buttonObject.focus()
下面的例子将在按钮上设置焦点:
<html>
<head>
<script type="text/javascript">
function setFocus()
{
document.getElementById('button1').focus()
}
</script>
</head>
<body>
<form>
<input type="button" id="button1" value="Button1" />
<br />
<input type="button" onclick="setFocus()"
value="Set focus to Button 1" />
</form>
</body>
</html>