Last active
March 23, 2019 17:17
-
-
Save luiscastro193/0d920a1219d9900fecc33e7d37d4400c to your computer and use it in GitHub Desktop.
Select input (JavaScript)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
function selectInput(input) { | |
setTimeout(function() { | |
try { | |
input.setSelectionRange(0, input.value.length); | |
} | |
catch(e) { | |
input.select(); | |
} | |
}, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment