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
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/openWindow.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.
@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
open
is not calling a function. you need to envoke a function with parentheses ()
.
change it to openImages()
or something.Okay thanks for the help @markboots.
no problem, good luck