Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gorangajic/select-text
Simple script to select text in document, just pass it dom element
https://github.com/gorangajic/select-text
dom javascript react
Last synced: 3 months ago
JSON representation
Simple script to select text in document, just pass it dom element
- Host: GitHub
- URL: https://github.com/gorangajic/select-text
- Owner: gorangajic
- Created: 2017-04-06T18:22:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-13T13:14:57.000Z (over 7 years ago)
- Last Synced: 2024-04-14T05:47:11.262Z (10 months ago)
- Topics: dom, javascript, react
- Language: JavaScript
- Homepage:
- Size: 1000 Bytes
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
> Simple script to select text in document, just pass it dom element
### Usage
```
npm install select-text
```Plain Javascript
```javascript
document.onclick = function(e) {
if (e.target.className === 'click') {
selectText(e.target);
}
};
``````html
Some text goes here!
Moar text!
Click me!
```With React
```jsx
{
selectText(e.currentTarget)
}}
>
Select Me!
```### Credits
Taken from http://stackoverflow.com/a/987376