Created
April 22, 2020 15:12
-
-
Save lenivene/201db347744e2acc9f63dcb47e788e6d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Document</title> | |
</head> | |
<body> | |
<input | |
id="el" | |
type="text" | |
value="https://blog.rocketseat.com.br/navegacao-react-native/" | |
/> | |
<script type="text/javascript"> | |
function addEvent(elem, event, fn) { | |
if (elem.addEventListener) { | |
elem.addEventListener(event, fn, false); | |
} else { | |
elem.attachEvent("on" + event, function() { | |
return fn.call(elem, window.event); | |
}); | |
} | |
} | |
var element = document.getElementById("el"); | |
addEvent(element, "focus", function() { | |
var that = this; | |
setTimeout(function() { | |
that.selectionStart = that.selectionEnd = that.value.length; // mude "that.value.length" para um número grande, se não funcionar | |
}, 0); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment