1 jQuery.fn.selText = function() {
  2     var obj = this[0];
  3     if ($.browser.msie) {
  4         var range = obj.offsetParent.createTextRange();
  5         range.moveToElementText(obj);
  6         range.select();
  7     } else if ($.browser.mozilla || $.browser.opera) {
  8         var selection = obj.ownerDocument.defaultView.getSelection();
  9         var range = obj.ownerDocument.createRange();
 10         range.selectNodeContents(obj);
 11         selection.removeAllRanges();
 12         selection.addRange(range);
 13     } else if ($.browser.safari) {
 14         var selection = obj.ownerDocument.defaultView.getSelection();
 15         selection.setBaseAndExtent(obj, 0, obj, 1);
 16     }
 17     return this;
 18 }
 19