Javascript Form How to - Remove the focus from the text area








Question

We would like to know how to remove the focus from the text area.

Answer


<!--   w w w  .  jav a2 s .  c o m-->
<html>
<head>
    <script language="JavaScript">
    function removeFocus(){
      document.myForm.myTextArea.blur();
    }
    </script>
</head>
<body>
    <b>Highlight some of the text in the following text area:</b>
    <form name="myForm">
       <textarea name="myTextArea" rows=6 cols=50>
       Here is some text in my text area.
       </textarea>
       <input type=BUTTON value="Click to Remove Focus" name="myButton" onClick="removeFocus()">
    </form>
</body>
</html>

The code above is rendered as follows: