Libraryless. Click here for Pure Java version (2698L/17K).
sS hjs_focusEnd() { ret hjs([[ $.fn.setCursorPosition = function(position, noFocus) { if(this.length == 0) return this; return $(this).setSelection(position, position, noFocus); } $.fn.setSelection = function(selectionStart, selectionEnd, noFocus) { if(this.length == 0) return this; var input = this[0]; if (input.createTextRange) { var range = input.createTextRange(); range.collapse(true); range.moveEnd('character', selectionEnd); range.moveStart('character', selectionStart); range.select(); } else if (input.setSelectionRange) { if (!noFocus) input.focus(); input.setSelectionRange(selectionStart, selectionEnd); } return this; } $.fn.focusEnd = function(noFocus) { this.setCursorPosition(this.val().length, noFocus); return this; } ]]); }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030311 |
Snippet name: | hjs_focusEnd - helper to move caret to end of text area |
Eternal ID of this version: | #1030311/2 |
Text MD5: | 1ec098b8a374d16a2333ca0fb4d7c086 |
Transpilation MD5: | f7218098eb482abb28a9503ad1b03b14 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-11-30 15:14:24 |
Source code size: | 987 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 98 / 146 |
Version history: | 1 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |