For example: the element a is created using an arbitrary function, inside the new element there are several elements that have their own id

This command will not work: (the function getElementById () is only in the document element)

a.getElementById('page_right').appendChild(b); 
  • Since the id on the page should be unique, you can easily call document.getElementById() . - Stepan Kasyanenko

1 answer 1

 a.querySelector('#page_right').appendChild(b);