title: How to activate text input on a button click in javascript
body: <p>I am trying to activate a text input using a button. 
  My function is like this.</p>
  
  <pre><code>function showHide4()
  {
   document.getElementById('snack').readOnly=false;
   document.getElementById('snack').style.backgroundColor"#ffffff";   
  }
  </code></pre>
  
  <p>This function makes text input writable and changes background to white, but it gets activated only after I click on it.</p>
  
  <p><strong>Note:- My idea of activated text input is cursor(|) blinking in it.</strong>  maybe activated is not a correct word for it but I don't know what else to call it.</p>
  
  <p><strong>EDIT:-</strong> I tried focus(), Problem in using focus() is Default value in my text input is getting selected automatically, which is not what I want, I want to put cursor(|) after that value.</p>