Is there a way to detect mouse click or mouse up event on text selection but actually skip when selecting text?
https://jsfiddle.net/chille1987/ctm4rd7n/
<div id="editor">
<p>What is Lorem Ipsum?</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum</p>
</div>
<div id="status"></div>
And here is my js code
$(function() {
$('#editor').on('mouseup', function(e) {
let selection = window.getSelection().toString().length;
let targetContainsSelection = e.target.contains(window.getSelection().baseNode);
if(selection > 0 && targetContainsSelection) {
$('#status').text('true');
} else {
$('#status').text('false');
}
});
})
Disired solution is to status text to be true only when i click on selected text but not when I'm selecting.