title: Text field select all / place cursor with jQuery
body: <p>I have a text field in an edit form that is pre-populated with a value. I would like to give it the following behaviour:</p>
  
  <ul>
  <li>clicking inside the text field automatically selects the entire contents</li>
  <li>Clicking again inside the area deselects all the contents and places the cursor in the position where the user clicks</li>
  </ul>
  
  <p>Here's my code:</p>
  
  <pre><code>// HTML
  &lt;input type="text" class="clickToSelect" value="myText" /&gt;
  
  // jQuery
  $(".clickToSelect").click(function(){
      $(this).select();
  })
  </code></pre>
  
  <p>Now when the user clicks the field, all the text is selected but when they click a second time all the text is still selected. Any ideas how I can deselect the text on the second click and place the cursor?</p>