Skip to content

Instantly share code, notes, and snippets.

View jamesperrin's full-sized avatar
✝️
Working it

James Perrin jamesperrin

✝️
Working it
View GitHub Profile
(function ($) {
/**
* jQuery plugin that places cursor at the end of text
* SEE: http://stackoverflow.com/questions/4609405/set-focus-after-last-character-in-text-box
* @param {Node} The input element
* @return {Node} The input element
*
*/
$.fn.focusTextToEnd = function () {
this.focus();
/*
* Places cursor at the end of text
* (c) 2019 James Perrin, MIT License, https://www.countrydawgg.com
* SEE: http://stackoverflow.com/questions/4609405/set-focus-after-last-character-in-text-box
* @param {Node} The input element
* @return {Node} The input element
*/
HTMLInputElement.prototype.focusTextToEnd = function () {
this.focus();
const thisVal = this.value;