Another thing I would change is the use of querySelector for selecting elements by id, just as a personal preference, I would rather go like document.getElementById("dynamic_id_here").querySelector("div").