Can I retrieve the user selected text in a text form input?
<p>I'm trying to get only the selected part of an input string that was selected by the user. Let's say I have this input :</p>

<pre><code>&lt;input type="text" name="first_name" id="first_name" value="Enter your name" /&gt;
</code></pre>

<p>And the user selects the "Enter" word by clicking and dragging in the text field. Can I retrieve that text with jQuery?</p>

<p>I know I can get the whole value this way :</p>

<pre><code>$("#first_name").val();
</code></pre>

<p>But so far, I didn't find anyway to get only the selected "Enter" part. Anyone is able to point me in the right direction? Thanks!</p>

<p><strong>EDIT</strong></p>

<p>I tried document.getSelection and it's working great in Firefox on a static text element such as a "p". It's not working for me so far on a text input.</p>

<p>In IE, window.selection.createRange().text is working both on a "p" and in a text input.</p>
