How to deslect highlighted text in textbox if already highlighted?
<p>So I have this very simple JS function that selects all the text in the ASP.NET texbox (input):</p>

<pre><code>function selectAllText(textbox) {
    textbox.focus();
    textbox.select();
}
</code></pre>

<p>..and it gets called like this on the click event:</p>

<pre><code>$("#&lt;%=Textbox1.ClientID %&gt;").click(function () { selectAllText(jQuery(this)) });
</code></pre>

<p>The problem is no matter how many times a user clicks in the text box <em>all of the text</em> is always selected. I understand why this is occuring (based on the way my code above is), but it doesn't work well when the user tries to click in the middle of a word to get the cursor back to make a modification to the text.</p>

<p>How do I modify this JS to tell if the text is already highlighted and then deselect the text? This was on subsiquient click, the user can get the single cursor on a precise clicked location to make a modification.</p>

<p>I am trying to get the documentation on the <code>.select()</code> method to see if I could do <code>if(!textbox.select())</code>, but I am having a hard time finding it, so post any doc links as well if you have them.</p>

<p><strong>EDIT:</strong> This problem and need for a workaround seems to be for IE (I am using IE9). In Chrome the behavior by default is what I need, but this is for an intranet application that runs on IE, so it appears I need an explicit workaround.</p>

<p>Thanks!</p>
