Forum Moderators: open
I have already built a simple text editor which allows the changing of a whole div's font style however I now want to make a bit more advanced and allow direct styling of highlighted text.
I've found a nice example of how to capture selected text for use in javascript but I now need be able to edit the selected text and it's surrounding tags. For example a user types "Hello World" selects "World" and adds a bold style, so the html is now "Hello <b>World</b>" (the tags are not displayed to the user), they then highlight "World" again and press delete.
I'm not sure how I would now make sure the tags as well as the word "World" are deleted. Some how I need to search for the next > character form the select point and the previous< although I'm not sure how to do this.