N
N
nak-alexey2018-04-07 13:47:37
JavaScript
nak-alexey, 2018-04-07 13:47:37

How to get the content of a tag without the content of the child elements?

Hello! There is a similar code structure

<div id="a">
Самый важный текст
<a id="b">Менее важный</a>
<a id="c">Вообще не нужен</a>
</div>


How to use JS to get the text only from ID A. If I do it with the help , then it returns the contents of the nested tags to me. How to be? Jquery $("#a").text()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor, 2018-04-07
@nak-alexey

document.getElementById('a').firstChild

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question