现在的位置: 首页 > 综合 > 正文

HTML DOM focus() 方法

2013年11月22日 ⁄ 综合 ⁄ 共 600字 ⁄ 字号 评论关闭
文章目录

HTML DOM focus() 方法

HTML DOM Anchor 对象参考手册

定义和用法

focus() 方法用于给予链接焦点。

语法

anchorObject.focus()

说明

该方法可滚动文档以使 Anchor 对象的位置变为可见。

实例

<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.w3school.com.cn">Visit W3School.com.cn</a>
<br /><br/>
<input type="button" onclick="getfocus()" value="Get focus">
<input type="button" onclick="losefocus()" value="Lose focus">
</body>

</html>

TIY

使用 focus() 和 blur()

HTML DOM Anchor 对象参考手册

【上篇】
【下篇】

抱歉!评论已关闭.