How to monitor window selection change event in javascript
Is there any method to monitor the c开发者_如何学运维hange event of window.selection?
Something like a callback, to be invoked when user select different content.
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">
Try the onSelect handler.
精彩评论