<html>
<body>
<input type="text" id="myText" value="文本域">
<p>点击按钮让文本域获取或者失去焦点。</p>
<button type="button" onclick="getFocus()">获取焦点</button>
<button type="button" onclick="loseFocus()">失去焦点</button>
<script>
function getFocus() {
document.getElementById("myText").focus();
}
function loseFocus() {
document.getElementById("myText").blur();
}
</script>
</body>
</html>