Solution 1 :

I believe you are looking for the textContent property of the div elements. So if you select a specific div (e.g. document.getElementById('print')), you can alter its textContent property like so document.getElementById('print').textContent = 5;

Solution 2 :

el.innerHTML.match(/-?d*.?d+/)[0]

Will pull the first numeric value found in the element. You will need to pull the element into el.

Problem :

I have started using javascript from today to create one plugin for firefox. I want to get the numeric value from a webpage which i will further use in a conditional statement. These value collectively create a timer on the webpage.

<div class="ureact-countdown_container-dark__3yLv6 ureact-countdown__container__AavqD queue-control-row_countdown__12Ijv">
        <div class="ureact-countdown_digit__3tqK_">
            02
            <span class="ureact-countdown_label__Mebe5">hr</span>
        </div>
        <div class="ureact-countdown_digit__3tqK_">
            35
            <span class="ureact-countdown_label__Mebe5">min</span>
        </div>
        <div class="ureact-countdown_digit__3tqK_">
            43
            <span class="ureact-countdown_label__Mebe5">sec</span>
        </div>
</div>

I want the numeric values stored in 3 variables.

I have saw some tutorials where they are using the following code to store the values mentioned within a class. But I have no prior knowledge on javascript.

var value = document.getElementsByClassName();

But as you can see all have the same class name, so how would i do that.

Any help or references will be appreciated from where I can learn.

Comments

Comment posted by Nicolas

Please paste your code in the question rather than posting a picture of it.

Comment posted by devlin carnate

Please update your question and add the relevant JS code snippet showing us your best attempt at resolving this yourself, and then explain at what point you’re encountering a problem.

Comment posted by Rajat Sharma

Hi @Nicolas I have modified the description. thanks in advance.

By