Created
September 1, 2015 09:45
-
-
Save victorbrender/a9b5cb04294a74cee3a1 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
jQuery.fn.selectText = function(){ | |
var doc = document | |
, element = this[0] | |
, range, selection | |
; | |
if (doc.body.createTextRange) { | |
range = document.body.createTextRange(); | |
range.moveToElementText(element); | |
range.select(); | |
} else if (window.getSelection) { | |
selection = window.getSelection(); | |
range = document.createRange(); | |
range.selectNodeContents(element); | |
selection.removeAllRanges(); | |
selection.addRange(range); | |
} | |
}; | |
$(function() { | |
$('#share_url').click(function() { | |
$('#share_url').selectText(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment