Skip to content

A jQuery plugin to fire off a custom/special event everytime a text is selected in the webpage.

Notifications You must be signed in to change notification settings

peol/jquery-text-selection-special-event

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Description

This plugin will let you bind a custom (special) event to your document, namely 'textselect'.

What this does is triggering an event when text is selected in the document, and returning the selected text plus the nearest element containing all the text. What this means is that if a text selection spans over several elements, e.g. <strong>, <strike> etc, it'll select the parent, as that DOM element is containing all the text that has been selected.

Please note, as of now, it doesn't support multi text selections in Webkit/Firefox.

Usage

$(document).bind('textselect', function (evt, string, element) { if (string != "") alert('Selected text (' + element.tagName + '): ' + string); });

About

A jQuery plugin to fire off a custom/special event everytime a text is selected in the webpage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published