S
S
Shmulhe2020-04-16 15:46:48
JavaScript
Shmulhe, 2020-04-16 15:46:48

Is it possible to immediately take the newly created tag using js into a variable without reloading the page?

Hi all.
https://codepen.io/Shmulhe/pen/Baojgmz
There is such a simple code. We drive words in Russian and English, they are added to the table. A button is also added that deletes these words (deletes table row from local storage as well). But there is a problem, in a variable:

let delWords = document.querySelectorAll('.delbtn');

which I want to pick up a piece of the newly created layout, nothing arrives (I want to pick up the buttons right away), it remains empty, although the tag has been created and comes to the variable only through f5, i.e. when the page is reloaded. Is there anything I can do to make it work without a reboot?
And in general it is correct to do so, i.e. create a piece of layout using js and immediately try to take it into variables?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question