Apply jquery css to contenteditable text selection
Can i apply css to selected text in a contenteditable div instead of using execcommand. For exmaple i would like to use jquery to apply css to a selected range such as $(savedRange).css({'color':'red'});
But that does work. Can this be done.
I already have the saveselection and restoreselection functions working where i can save 开发者_JAVA百科and restore selected text. The variable savedRange is what contains the saved text.
You will need to wrap the selected text with a inline element (such as a span) and then style that element. You can try the wrap function. It would be hard to say for sure without having an example.
$(savedRange).wrap('<span />').css({'color':'red'});
How can I use jQuery to apply css to savedRange text selection?
精彩评论