开发者

How to monitor window selection change event in javascript

开发者 https://www.devze.com 2023-02-14 08:02 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号