HTML DOM focus() 方法
定義和用法
focus() 方法用于給予鏈接焦點。
語法
anchorObject.focus()
說明
該方法可滾動文檔以使 Anchor 對象的位置變?yōu)榭梢姟?/p>
實例
<html>
<head>
<style type="text/css">
a:active {color:green}
</style>
<script type="text/javascript">
function getfocus()
{document.getElementById('myAnchor').focus()}
function losefocus()
{document.getElementById('myAnchor').blur()}
</script>
</head>
<body>
<a id="myAnchor"
href="http://www.dhdzp.com">Visit jb51.net</a>
<br /><br/>
<input type="button" onclick="getfocus()" value="Get focus">
<input type="button" onclick="losefocus()" value="Lose focus">
</body>
</html>