https://github.com/EvandroLG/selecting
:fishing_pole_and_fish: A library that allows you to access the text selected by the user
https://github.com/EvandroLG/selecting
javascript selecting
Last synced: 6 months ago
JSON representation
:fishing_pole_and_fish: A library that allows you to access the text selected by the user
- Host: GitHub
- URL: https://github.com/EvandroLG/selecting
- Owner: EvandroLG
- Created: 2014-12-29T01:00:55.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-10-22T18:57:17.000Z (about 10 years ago)
- Last Synced: 2025-05-01T06:02:25.575Z (6 months ago)
- Topics: javascript, selecting
- Language: JavaScript
- Homepage:
- Size: 331 KB
- Stars: 94
- Watchers: 3
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-javascript - selecting - A library that allows you to access the text selected by the user - ★ 69 (String)
README
# selecting
A library that allows you to access the text selected by the user.
## Instalation
To install Selecting, execute:
```shell
npm install selecting
```
Or Bower too:
```shell
bower install selecting
```
Or simply pick up the file from src directory.
## Supported Browsers
* Google Chrome
* Firefox
* Internet Explorer 9.0+
* Safari
* Opera
* iOS
* Android
## How to use?
Selecting doesn't depend on jQuery, Zepto or any other library to work. You need just to include it at the end of your HTML code:
```html
```
Then you can call window.selecting function passing two parameters: an DOM element (jQuery object or NodeList) to listen to and a callback function that receive a [Selection](https://developer.mozilla.org/en-US/docs/Web/API/Window.getSelection) object by parameter. For example:
```js
window.selecting($('.container'), function(selector) {
// Properties
selector.text; // The selected text
selector.wordCount; // The number of words selected
});
```
## Example
[See a simple example](http://evandrolg.github.io/selecting).
## Contributors
|[](https://github.com/evandrolg)|[](https://github.com/felquis)|[](https://github.com/gibatronic)|
|:---:|:---:|:---:|
|[@evandrolg](http://www.github.com/evandrolg)|[@felquis](http://www.github.com/felquis)|[@gibatronic](http://www.github.com/gibatronic)|