64
rated 0 times
[
67]
[
3]
/ answers: 1 / hits: 49290
/ 10 Years ago, wed, february 19, 2014, 12:00:00
I'm trying to set the cursor in a text field with a focus function. I've made some research but none of the provided solutions seemed to work in Google Chrome. In Internet Explorer and Firefox this solution is working fine:
The js:
$('#Search').focus(function() {
var SearchInput = $('#Search');
var strLength= SearchInput.val().length;
SearchInput.focus();
SearchInput[0].setSelectionRange(strLength, strLength);
});
The HTML:
<input type=text id=Search value=Hello World />
Here's the link to my jsfiddle.
Is there any way to make this work in Google Chrome too?
More From » jquery