Highlight changes

There are three types of changes: * Insertions * Deletions * Changes I would like to highlight all of them

HTML

<p id="old">I love you very much today</p>
<p id="new">I love you very mach nit</p>

CSS

.high {
    color: red;
}

JavaScript

highlight($("#new"), $("#old"));

function highlight(newElem, oldElem){ 
    var newText = newElem.text();
    var oldText = oldElem.text();
     
    var text = "";
    var spanOpen = false;
    newElem.text().split("").forEach(function(value, index){
				if (value != oldText.charAt(index)){   
            text += !spanOpen ? "<span class='high'>" : "";
            text += value;
            spanOpen = true;
        } else {       
            text += spanOpen ? "</span>" : "";
            text += value;
            spanOpen = false;  
        }	
    });
    newElem.html(text);
}