For my html application I want to do an action every time that some text is selected.
Right now I’m using the mouseup event to catch text selection like shown in the code below. But on mobile devices this does not work since mouseup is not fired after a selection. Which event can I use instead?
$("#container-around-text").on('mouseup', function() {
// check if selection is empty
// then do something
});
You could maybe store a variable selectedText and run an interval every 100ms or so that checks to see if the current selected text is the same as that store in selectedText variable. If it is different, perform an action.