Created
July 5, 2020 15:50
-
-
Save antiops/37f1e66a77fcf4ad29a71cab8506da0a to your computer and use it in GitHub Desktop.
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
// onclick="select_all(this)" | |
function select_all(el) { | |
if (typeof window.getSelection != "undefined" && typeof document.createRange != "undefined") { | |
var range = document.createRange(); | |
range.selectNodeContents(el); | |
var sel = window.getSelection(); | |
sel.removeAllRanges(); | |
sel.addRange(range); | |
} else if (typeof document.selection != "undefined" && typeof document.body.createTextRange != "undefined") { | |
var textRange = document.body.createTextRange(); | |
textRange.moveToElementText(el); | |
textRange.select(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment