focus: set the focus to the textarea control

 
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
    <form name="myForm">
      <textarea id="myTextArea1" rows=2 cols=50>
         Here is the first text area.
      </textarea>
      <input type="button" value="Click to Set Cursor" name="myButton1" onClick="setFocus()">
    </form>
  <script type="text/javascript">

        function setFocus(){
          var mySpan = document.getElementById("myTextArea1");
            mySpan.focus();
        }

  </script>
</body>
</html>
  
Click to view the demo
Home 
  JavaScript Book 
    DOM  

HTMLTextAreaElement:
  1. HTMLTextAreaElement
  2. focus: set the focus to the textarea control