1

I'm using jQuery's click function to check the formatting of highlighted text, however the function isn't always called.

If you highlight part of a line it will work as expected, however if you highlight the entire line it simple doesn't call at all.

Here is a JSFiddle for you to try it out: http://jsfiddle.net/ZMYRH/

Is there any chance I'm using this function incorrectly? Or is there a workaround to what I want to achieve?

0

1 Answer 1

2

The issue is because a click event is only fired if the mousedown and mouseup event occur on the same element.

In your case the mouseup event would be more appropriate as it will allow the user to drag a selection across elements.

Updated fiddle

Sign up to request clarification or add additional context in comments.

2 Comments

This doesn't seem to have solved the problem, I'm getting the same results. Are you sure you didn't carefully select from the text still instead of the whitespace?
When selecting from the grey box (i've added in this fiddle: jsfiddle.net/ZMYRH/2) all the way to the end of the line, it doesn't respond.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.