You can do this using Input.setSelectionRange
, part of the Range API for interacting with text selections and the text cursor:
var searchInput = $('#Search');
// Multiply by 2 to ensure the cursor always ends up at the end;
// Opera sometimes sees a carriage return as 2 characters.
var strLength = searchInput.val().length * 2;
searchInput.focus();
searchInput[0].setSelectionRange(strLength, strLength);
Demo: Fiddle
Related Contents:
- How to apply !important using .css()?
- Using jQuery to center a DIV on the screen
- How to disable HTML links
- horizontal scrollbar on top and bottom of table
- Replacing css file on the fly (and apply the new style to the page)
- Refresh/reload the content in Div using jquery/ajax
- JSFiddle code not working in my own page
- How to style “input file” with CSS3 / Javascript? [duplicate]
- How to disable scroll without hiding it?
- Changing nav-bar color after scrolling?
- jQuery: Get selected element tag name
- How do I detect “shift+enter” and generate a new line in Textarea?
- How to silently hide “Image not found” icon when src source image is not found
- How to close an open collapsed navbar when clicking outside of the navbar element in Bootstrap 3?
- How to show popup message like in Stack Overflow
- Use images like checkboxes
- Bootstrap Dropdown with Hover
- How to auto-scroll to end of div when data is added? [duplicate]
- How to dynamically create ‘@-Keyframe’ CSS animations?
- Setting CSS value limits of the window scrolling animation
- Dashed border animation in css3 animation
- :touch CSS pseudo-class or something similar?
- CSS3-Animate elements if visible in viewport (Page Scroll)
- Open a new javascript window(.open) along with its CSS styling
- Use a new CSS file to override current website’s
- Fade background image in and out with jQuery?
- How to create a responsive image that also scales up in Bootstrap 3
- jQuery – Sticky header that shrinks when scrolling down
- How to ONLY trigger parent click event when a child is clicked
- How to swipe top down JQuery mobile
- Scale element proportional to Background Cover with jQuery
- jQuery jump or scroll to certain position, div or target on the page from button onclick [duplicate]
- Uncaught TypeError: Cannot read property ‘top’ of undefined
- Detect browser wrapped lines via javascript
- jQuery Validation using the class instead of the name value
- Change the style of :before and :after pseudo-elements? [duplicate]
- Fill available spaces between labels with dots or hyphens
- JavaScript Loading Screen while page loads
- Check if element is between 30% and 60% of the viewport
- Active Menu Highlight CSS
- Can I save input from form to .txt in HTML, using JAVASCRIPT/jQuery, and then use it?
- Changing image on hover
- Increase CSS brightness color on click with jquery/javascript?
- jQuery in Chrome returns “block” instead of “inline”
- How to display Image dynamically on UI?
- collapse and expand tabs jquery / simple accordion
- Bootstrap Dropdown menu is not working
- Large dynamically sized html table with a fixed scroll row and fixed scroll column
- Prevent iOS bounce without disabling scroll ability
- Select a row from html table and send values onclick of a button