I got ten elements and I store them by querySelectorAll or getElementsByClassName(which return live HTML collections). Imagine they're all having the same class name, I got a PHP function to filter them, so currently, only three of them are generated by PHP once the page is loaded, as I init the filter function, the other elements then only being generated.
But the variable is still storing the initial dom elements which are the three elements originally shown before the filter. Now how do I update the variable so that they include the new elements that are newly generated like after the filter button is clicked?