Reputation: 21
I have
<span class="blnc-ind"></span>
and
<a class="blnc-ind__income" href="/profile/money">1,13 $</a>
inside of it
I want to get data of
<a class="blnc-ind__income" href="/profile/money">1,13 $</a>
that is only 1,13 $
without any code
I was tried to use this command:
document.getElementsByClassName('blnc-ind__income');
but console show it only this way:
[ <a class="blnc-ind__income" href="/profile/money">1,13 $</a> ]
Please, help me to solve this problem
Upvotes: 0
Views: 44
Reputation: 68665
Try to use
document.getElementsByClassName('blnc-ind__income')[0].textContent;
This function returns to you an array not a single element, so you need to get your element by the indexing.And then to get the content of that element
document.getElementsByClassName
Difference between textContent
and innerHTML
textContent uses straight text, does not parse HTML, and is faster.
innerHTML parses content as HTML and takes longer.
Upvotes: 1