![](/img/trans.png)
[英]Detect when text is entered into the textarea and change it correspondingly
[英]Detect when user selects text in a textarea
如何检测用户何时使用JS在textarea中选择文本? 我使用了jQuery-fieldselection,但只有将range.text
放入pre标签时它才有效。它不适用于div。
使用select
事件。 它适用于所有主流浏览器中的<textarea>
和<input type="text">
元素。 对其他要素的支持并不普遍。
document.getElementById("your_textarea").onselect = function() {
alert("Select");
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.