Hi.
I have this JS code below. It extracts the text from my bs element. However, some of the text in the bs elements have HTML italics tag, but the code excludes the text in the italics tags while extracting the rest. How can I edit the code to also include the text in the italics tag?
I have this JS code below. It extracts the text from my bs element. However, some of the text in the bs elements have HTML italics tag, but the code excludes the text in the italics tags while extracting the rest. How can I edit the code to also include the text in the italics tag?
HTML:
<bs id="27:46" onClick="getText(document.getElementById('vs1031'));">
<b> 46</b></bs>
<vs id="vs1031">About the ninth hour Jesus called out with a loud voice, saying: <i>“E´li, E´li, la´ma sa·bach·tha´ni?” that is,</i> “My God, my God, why have you forsaken me?”</vs>
Code:
function getText(what) {
var result =''
for (var i = 0, l = what.childNodes.length; i < l; i++)
if (what.childNodes[i].nodeType == Node.TEXT_NODE)
result += what.childNodes[i].textContent
return result.replace(/\s+/g, ' ')
}