<div class='user'><img src='*' class='avatar float-left'> <div>нужное значение*</div></div> 

There is an HTML page. In this code, you need to display only the "desired value *" using JS. On the page of such a div a whole bunch, so that the number will not work. "The required value *" is replaced with a random word (user nickname) after a certain time. Maybe there is an option to somehow find the class 'user' and inside with a div to display this "desired value *"? Trying to do this:

 function find_name() {var value_name = document.getElementsByClassName("userinfo"); document.title = value_name.innerHTML; } 

Naturally, this code is not enough and the title flies "undefined". Can there be any option through JS to drop into the desired value * at least id on the fly? Those. to get the desired value *. Let me remind you that when you load the page, the "desired value *" is already substituted and the following is not known - it does not repeat. Page someone else and can not be replaced.

    1 answer 1

    I misunderstood you

     const value = document.querySelector('.user.name .avatar + div') console.log(value.textContent) 
     <div class='user name'> <img src='*' class='avatar float-left'> <div>нужное значение*</div> </div> <div class='user'> <img src='*' class='avatar float-left'> <div>не нужное значение*</div> </div> 

    • Briefly and a little differently, I need what's between the <div> tag, and this is the “right value *”. This value which goes to the conclusion is not known. The result must be assigned to a variable, so that it can be used for the necessary purposes. For example, in the title of the page to display the result. All this is posted on the page via Tampermonkey with the addition of JS. It seems your way came up. I will try in combat conditions. - Vasily Pupkin
    • Between which div tag? - Ilya Zelenko
    • <div> right value * </ div> The problem was that I could not access this div through getElementBy, because tag does not contain class or id. and on the div page a lot. - Vasily pupkin
    • then I showed through which selector to apply, my code displays that inside a div (the necessary value *) - Ilya Zelenko
    • Can you please tell me how to access <div class = 'user name'> if there is a space? Similar to the code as before, adding only a space and name. - Vasily pupkin