jquery focus input end of text

Solutions on MaxInterview for jquery focus input end of text by the best coders in the world

showing results for - "jquery focus input end of text"
June
16 Jun 2017
1<input type="text" id="Search" value="Hello" />
2
3var searchInput = $('#Search');
4
5// Multiply by 2 to ensure the cursor always ends up at the end;
6// Opera sometimes sees a carriage return as 2 characters.
7var strLength = searchInput.val().length * 2;
8
9searchInput.focus();
10searchInput[0].setSelectionRange(strLength, strLength);