Reputation:
It is there any method that I can use to recovery deleted element?
This is my code for remove the element
myFunction() {
var width = window.innerWidth;
var February = document.getElementById('February');
if(width <= 1114)
{
if(February != null)
February.remove();
}
}
I need restore the element when the width is more than 1114 (e.g.)
Any ideas? Thank you!
Upvotes: 0
Views: 402
Reputation: 207557
There is no need to use JavaScript. With CSS Media Queries and display:none, you can remove the element from the document. No JavaScript is needed to listen for resize events, the browser does it for you with CSS
@media only screen and (max-width:1114px){
.hide-max {
display: none;
}
}
<div class="hide-max">This is hidden when under max</div>
Upvotes: 1