I required a trigger, whenever the window
text selection cleared.
Finally I found this approach.
Using the same id
, I have added multiple event handlers, but I am not sure my work is the best.
Is there a better way to do this?
$('#tenderContent').on('mouseup', '.tenderdocument', function (e) {
e.stopPropagation();
if ($.trim(window.getSelection().toString()).length) {
$('#text').text(window.getSelection().toString());
}
});
$('#tenderContent').on('mousemove', '.tenderdocument', function (e) {
e.stopPropagation();
if (!$.trim(window.getSelection().toString()).length) {
$('#text').empty();
}
});
jsfiddle
i placed the sample code. that's not integrated. but my app, i did not get any issue. still the code may not such good! \$\endgroup\$