18 lines
389 B
JavaScript
18 lines
389 B
JavaScript
function getElementChildrenInnerText(element) {
|
|
let text = '';
|
|
for (const child of element.children) {
|
|
if (child.type === 'text') {
|
|
text += child.data.trim();
|
|
}
|
|
if (child.children !== undefined) {
|
|
text += getElementChildrenInnerText(child);
|
|
}
|
|
}
|
|
|
|
return text;
|
|
}
|
|
|
|
module.exports = {
|
|
getElementChildrenInnerText,
|
|
};
|