Revision: 47472
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 8, 2011 18:34 by griffpup
Initial Code
<div id="selectme" contenteditable='true'>Some text goes here!</div> <p>Click me!</p> function SelectText(element) { var text = document.getElementById(element); if ($.browser.msie) { var range = document.body.createTextRange(); range.moveToElementText(text); range.select(); } else if ($.browser.mozilla || $.browser.opera) { var selection = window.getSelection(); var range = document.createRange(); range.selectNodeContents(text); selection.removeAllRanges(); selection.addRange(range); } else if ($.browser.safari) { var selection = window.getSelection(); selection.setBaseAndExtent(text, 0, text, 1); } } $(function() { $('p').click(function() { SelectText('selectme'); }); });
Initial URL
Initial Description
Initial Title
jquery select text
Initial Tags
textmate, jquery
Initial Language
Other