execcommand on empty selection
问题 I'm working on a specialized Text/HTML Editor with Javascript and JQuery in a contenteditable div. I implemented the different text styles (bold, italic,...) with execcommand. This seems to work only if the selected text is not empty. What is the best way to solve this problem? Here an example of what I want to do with Text being the text in the editor, HTML being the corresponding html code and | being the cursor Position: Text: Hello| World HTML: <b>Hello| World</b> By pressing a "bold"