I am trying to create a simple CMS where users can write anything in a contenteditable div. When they save their work, I want to remove certain characters from the text that they put ie:
Text:
<ul> <li>This is the text inserted by <b>user</b> and styled by him - there should be no comma at the end of a <b><i><u>LI element,</u></i></b></li> </ul>
I know how to remove a comma using jquery.text (), but it just gives me plain text without HTML tags. The problem is that I don’t know if or how many HTML tags there will be at the end of the sentence, where the comma should be removed.
Is there any other way to remove this comma without touching the HTML tags? So, after saving the work, the text would remain stylish, as it should be, but without a comma at the end of the LI element?
Simple fiddle: jsfiddle
source share