fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <input type="text" id="myText" value="文本域"> <p>点击按钮设置或移除以上文本域的焦点。</p> <input type="button" onclick="getfocus()" value="获取焦点"> <input type="button" onclick="losefocus()" value="移除焦点"> <script> function getfocus() { document.getElementById("myText").focus(); } function losefocus() { document.getElementById("myText").blur(); } </script> </body> </html>
运行结果