The problem that dynamic rendering data can not be traversed when getting elements through class

according to the data returned by the background, it is displayed on the page (commodity editing function). The data is an array that needs to be rendered in a loop (but there is a set of arrays in it). The interior of the circular rendering also includes components referenced from the outside. Because the element is dynamically rendered based on the data, this component cannot be obtained using ref, so instead use class to get the sub-component element, and then loop to assign values to the elements in its page to reflect the data.
but now the problem is that you can get the list of sub-component elements after the loop (collection list), but cannot be traversed, that is, console.log (document.getElementsByClassName ("plaCate") [0]) is undefined, as shown in the following figure, traversal is terminated, and elements cannot be traversed. Ask for advice ~


I see you have two HTMLCollection objects in the console, the first time there are two elements, and the second time it is empty. Is it true that you have manipulated two div in the forEach loop, causing them to disappear from the page node?

Menu