Slavik
Slavik

Reputation: 1083

How to monitor window selection change event in javascript

Is there any method to monitor the change event of window.selection?

Something like a callback, to be invoked when user select different content.

Upvotes: 3

Views: 1598

Answers (2)

Benson
Benson

Reputation: 22847

If you're using jQuery, and you want to handle select on a specific item with an ID of myInput, you can do this:

$("#myInput").select(function() { alert("Something was selected!"); });

Otherwise, I think you'd need to add it in HTML, like this:

<input type="text" onSelect="alert('foo');" value="default text">

Upvotes: 2

Sjoerd
Sjoerd

Reputation: 75619

Try the onSelect handler.

Upvotes: 0

Related Questions