当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > HTML DOM focus() 方法

HTML DOM
DOM TableRow 对象
DOM Textarea 对象
DOM Window 对象

HTML DOM focus() 方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 436 ::
收藏到网摘: n/a

定义与用法

The focus() method is used to give focus to a link.
使用focus() 方法可以聚焦到某个连接

语法

anchorObject.focus()


举例

<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.ruanchen.com">访问 ruanchen.com</a>

<br /><br/>
<input type="button" onclick="getfocus()" value="Get focus">
<input type="button" onclick="losefocus()" value="Lose focus">

</body>
</html>


尝试与演示

Using focus() and blur()
使用focus()和blur()

评论 (0) All

登陆 | 还没注册?