1

I have a page with formated text and a toolbar (images with click events) beside it. One of the tool-commands is meant to be "mark yellow". (The text has to be read only and is formated.)

I tried to use document.getSelection() and window.getSelection(), but they seem to be designed for input fields only.

The other problem is, that as I click the tool bar my selection gets lost.

How do I get the selected text without loosing the selection?


Solution:

The clue was to use onmousedown="" or jQuery: .mousedown() function to avoid loosing the selection.

1 Answer 1

1

Here is how to get text selection with Javascript.

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

Comments

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.