I am having issue removing dynamically added attributes from HTML. There is a parent component(not controlled by me) which has a click functionality where it calls an API and adds a HTML element to the DOM. Now i have to remove this element from DOM when the click functionality is done and HTML is rendered. I tried below two methods, but did not had luck as the element is unavailable
window.addEventListener('load', function(){
const ele = document.getElementById("remEle");
console.log(ele)
})
$(document).ready( function() {
const ele = document.getElementById("remEle");
console.log(ele)
})
<div id="container">
<div class="header-class" id="remEle">
"Header"
<div class="item-class">item</div>
</div>
</div>
In both the cases i am getting "ele" as undefined and not able to remove it.