select-text
v1.0.1
Published
http://stackoverflow.com/a/987376
Downloads
325
Readme
Simple script to select text in document, just pass it dom element
Usage
npm install select-text
Plain Javascript
document.onclick = function(e) {
if (e.target.className === 'click') {
selectText('selectme');
}
};
<div id="selectme"><p>Some text goes here!</p><p>Moar text!</p></div>
<p class="click">Click me!</p>
With React
<div
onClick={(e) => {
selectText()
}}
>
Select Me!
</div>
Credits
Taken from http://stackoverflow.com/a/987376