Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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