HTML DOM focus() ·½·¨
¶¨ÒåºÍÓ÷¨
focus() ·½·¨ÓÃÓÚ¸øÓè¸ÃÔªËØ½¹µã¡£ÕâÑùÓû§²»±Øµã»÷Ëü£¬¾ÍÄܱà¼ÏÔʾµÄÎı¾ÁË¡£
Óï·¨
textareaObject.focus()
ʵÀý
ÏÂÃæµÄÀý×ÓÉèÖò¢ÒÆ¿ªÁËÎı¾¿òÉϵĽ¹µã£º
<html> <head> <script type="text/javascript"> function setFocus() {document.getElementById('txt1').focus()
} function loseFocus() {document.getElementById('txt1').blur()
} </script> </head> <body> <textarea id="txt1">Hello world....</textarea> <br /> <input type="button" onclick="setFocus()" value="Set focus" /> <input type="button" onclick="loseFocus()" value="Lose focus" /> </body> </html>