I have a difficult situation with html and javascript. My html page allows user to select text and highlight it with colors. Now I want to save the state into database to sh
from a testing perspective, there is no way to store detached highlights if it is possible to alter the original html without also adjusting the highlights.
my solution would be to serialize the entire colored html. then make a scrub function to remove all color highlights and return to the baseline html. this allows the html in the db to include the color highlights and editing can still occur with highlighting preserved.
something like:
function unhighlight() {
$('.highlighted').each(function(index, el) {
$(el).replaceWith($(el).html());
});
}
jsfiddle: https://jsfiddle.net/tobtedsc/5/