0

Seems like a weird problem but probably a simple answer.

Check out this CodePen.

You'll see that I've set it up where on mousedown, it checks for selected text. If true and not empty, it sets text_selected to 1 (or true) and returns the selected text.

On mouseup, if text_selected is true, it should print 1 and the selected text... but it doesn't!

If you click it a 2nd time it will, but that's no good. Why isn't it updating prior to mouseup?

Casey Dwayne
  • 2,142
  • 1
  • 17
  • 32
  • This does not look right `$(window).on('mousemove',checkForSelectedText());` try without the () – mplungjan Dec 26 '13 at 22:14
  • @mplungjan I swear that gets me every time. Works like a charm now - thanks! – Casey Dwayne Dec 26 '13 at 22:16
  • 1
    It seems to me that binding on mouse up is sufficient: `$(window).on('mouseup', function(e) { showSelectedText()});` the function `showSelectedText` is only a wrapper around your code: `$('.ph').text('Text selected: '+checkForSelectedText());` – surfmuggle Dec 26 '13 at 23:23
  • True. It does encompass all I'm desiring to do with one event. – Casey Dwayne Dec 27 '13 at 00:06

0 Answers0