Select first character of input value with jQuery
<p>I have some input fields that are pre-filled through jQuery. I'd like to grab the value of an input, check if it starts with "x" and if it does, select that x. (So that the user can quickly change the x by just typing something else).</p>

<p>I know there is a question like this here: <a href="https://stackoverflow.com/questions/3085446/selecting-part-of-string-inside-an-input-box-with-jquery">Selecting Part of String inside an Input Box with jQuery</a></p>

<p>But it's a really old question and it doesn't really use jQuery!</p>

<p>So, how can I select the x in this input's value?</p>

<pre><code>&lt;input class="input" type="text" value="x*500*500" /&gt;
</code></pre>

<p>I tried:</p>

<pre><code>var input = $('.input');
input.setSelectionRange(0, 2); // Highlights "X"
input.focus();
</code></pre>

<p>error: <code>Uncaught TypeError: input.setSelectionRange is not a function</code>. Is <code>setSelectionRange</code>deprecated?</p>