S
S
Svyatoslav2020-02-01 10:24:14
JavaScript
Svyatoslav, 2020-02-01 10:24:14

How to display the value of a variable from the site to the console?

<h6 class="card-sub-title">
                                        myname;)                                    </h6>
<span style="    color: #fff;font-weight: 500;font-size: 1.6em;line-height: 1;letter-spacing: -0.02em;" mybalance="52.58" class="odometer" id="userBalance">
52.58</span>
 </div>


How to print the value of mybalance to the console?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2020-02-01
@6e3likii

You need to do not mybalance but data-mybalance
Then you need to get the element that has the attribute you need, and then find it by name and output it to the console. https://developer.mozilla.org/ru/docs/Web/Guide/HT... https://developer.mozilla.org/ru/docs/Web/API/Elem...
console.log(el.getAttribute('data-mybalance'))

I
Innoel, 2020-02-01
@Innoel

If I understand correctly what is required, then here is an example, there are two ways. In fact, there are more of them, of course.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question