We want to remove a div with the ID
const elem = document.getElementById('custom_id'); elem.remove();
And yes, that's how simple it is!
But perhaps you only want to hide it for a brief moment? We can also modify the script to make the element invisible for a while.
const hidden = document.getElementById('hidden_id'); hidden.style.display = 'none';
And that will make your element hidden until you make it visible again.
It can be made visible by swapping the display to block/flex/inline.
const hidden = document.getElementById('hidden_id'); hidden.style.display = 'block';
Feel free to check this out on Codepen.
Thank you for reading, and let's connect!
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter