A page is dynamically added to the page (I don’t know whether it’s true to say so about it or not, but that's not the point) a node (div tag with the class "shop"). it creates three more divas. When you click "exit" this node should be removed. I do it this way, the function is hung on the button:

stopShop: function(_context){ var container = document.getElementsByClassName('shop'); var contDiv = container.getElementsByTagName('div'); //console.log(container); container.removeChild(contDiv); } 

but TypeError: container.getElementsByTagName is not a function error, help me figure it out, please.

    1 answer 1

    because getElementsByClassName returns a collection (Returns an array-like object according to the Mozilla version), and not an element - because there can be> 1 elements with the same class.

    You need to refer to an element in this collection to use element.getElementsByTagName()