Skip to content Skip to sidebar Skip to footer

Losing Selected Text From Contenteditable On Clicking Div With Css User-select: None;

I'm developing a JavaScript rich text editor. Instead of buttons, I'm using div with css property user-select: none. This works fine in Firefox but problem is with Google Chrome. W

Solution 1:

Use buttons, intead of div or span for making clickable links to change style.

And then use document.execcommand('forecolor',false,'#000000');

Solution 2:

I have a similar setup, and the following solution works fine in Chrome: How to disable text selection using jQuery?

The answer is to add a handler for the 'selectstart' event.

Post a Comment for "Losing Selected Text From Contenteditable On Clicking Div With Css User-select: None;"