I know that document.createTextNode(text) in JS is for creating text only, but is there a way to insert into it two span elements?
I have two spans created like this:
/*
* span with wrong (old) medical word
*/
// Replacement node
var span_old = $('<span />', {
'class': pluginName + '-autoword-highlight wrong wrong-medical-word-'+i
});
// If we have a new match
if (i !== c) {
c = i;
replaceElement = span_old;
}
span_old
.text(fill)
.data({
'firstElement': replaceElement,
'word': oldWord
});
/*
* span with new - corrected medical word
*
*/
// Replacement node
var span_new = $('<span />', {
'class': pluginName + '-autoword-highlight corrected-medical-word-'+i
});
// If we have a new match
if (i !== c) {
c = i;
replaceElement = span_new;
}
span_new
.text(replaceFill)
.data({
'firstElement': replaceElement,
'word': replaceFill
});
var wrong_and_corrected_medical_text = span_old[0] + span_new[0];
return document.createTextNode(wrong_and_corrected_medical_text);
Expected result is
old text - new text
and I need to return Text Node as always. Is there a hack to stringify the span elements or other way? Thanks!