First: I am not entirely sure of the difference between ranges and selections.

I want to:

  1. Highlight some text

  2. Click on a button and wrap a class around the selected text (I am able to do this using rangy, BUT rangy needs the text to be in a highlighted state, BUT that click removes the highlight on the text.)

Question:

How do i reproduce the highlighted text after that click, so that rangy has something to work with?

Thanks!

有帮助吗?

解决方案

There is an example on the rangy code repository that does exactly what it seems you want.

Have a look at this: http://rangy.googlecode.com/svn/trunk/demos/highlighter.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top