Deselect only text with one certain class on mousemove

128 Views Asked by At

Let's say I have some text with the class .a and some more text with the class .b.

How to unselect only text with the class .a on mousemove, instead of all text like in this fiddle:

http://jsfiddle.net/Lx5bbrk2/

$('*').mousemove(function(){
    document.getSelection().removeAllRanges(); //deselects all text, needs to be modified
});

I don't know how to put selector into this.

note: select text with ctrl+a or with double click.

edit:

nevermind spans. this fiddle is just a quick illustration. real situation is simple - different text classes are in different divs.

different classes are also different element types - spans and contenteditable divs. doesn't really matter how certain text gets deselected, as long as it's not the whole document.

So is this even possible?

0

There are 0 best solutions below