first commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
//From http://stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse
|
||||
;(function($) {
|
||||
$.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);
|
||||
}
|
||||
element.focus();
|
||||
};
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user