Whole DOM getting deleted when using display 'none' property for an id element

I want a specific id element to be deleted when I onclick a button. But when clicking the "Hide Images" button, instead of the id element the whole DOM is getting deleted. Does anybody have any idea why it is behaving like this. Here is the codepen - https://codepen.io/adarsh88/pen/vYaXwbN
5 Replies
MarkBoots
MarkBoots2y ago
You are using a reserved method in the onclick. The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values. So, give it another name. https://developer.mozilla.org/en-US/docs/Web/API/Window/open
Window.open() - Web APIs | MDN
The open() method of the Window interface loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name.
Adarsh
AdarshOP2y ago
@markboots. When I change open() to open, the display"none" style is not applying on clicking the "hide image" button Any idea where I am wrong
MarkBoots
MarkBoots2y ago
open is not calling a function. you need to envoke a function with parentheses (). change it to openImages() or something.
Adarsh
AdarshOP2y ago
Okay thanks for the help @markboots.
MarkBoots
MarkBoots2y ago
no problem, good luck
Want results from more Discord servers?
Add your server