Skip to content
Advertisement

Tag: shared-libraries

JavaScript get textContent excluding children

First, I’m creating a library for JavaScript and I can not use jQuery. I’m trying to get the text content of an HTML element without the text contents of its children. Both attributes innerText and textContent don’t give me what needed, please help. Answer You can solve using DOM API as childNodes and nodeType. I created a sample code as

Advertisement