'Accessing the created element

response.data = <div id="login">Hi</div>

How to refer to the newly created element, let's say I inserted html code, a div appeared at the bottom of the page and I need to refer to it?

   document.body.insertAdjacentHTML('beforeend', response.data)

   thisModal = document.getElementById('login')


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source