How to determine when a user selects text in a text field using JS? I used jQuery-fieldselection, but it only works if range.textplaced in pre tag.It does not work with div.
range.text
Use an event select. It works for elements <textarea>and <input type="text">in all major browsers. Support is not universal for other elements.
select
<textarea>
<input type="text">
document.getElementById("your_textarea").onselect = function() { alert("Select"); };
It also works in the div, http://phpjs.org/functions/nl2br:480 .