Can someone explain this code?

Can someone explain this code?
0.0 0


I stumbled upon this function of JS in w3schools and im curious about windows.onlick, function(event) and == modal, what they are and how they work? I know == modal could be that event targets the modal, does it mean that when we use window.onlick, it means clicking anywhere on window? And later asign it function(event) for what ever event to work in this case clicking anywhere on window but if we click anywhere on window to make Modal in this code to dissapear since it was styled as display:none in If statement? Am i understanding this well? Why did he use == modal? event needs to equal what we wish to trigger?


window.onlick means that you attach a click handler on the window. This handler function should then be called each time the user clicks the window area. The function would receive the event object event which contains metadata about the event. The property is the actual element that the user targeted/clicked on inside the scope (window). In your example it tests if the user clicked the element with id id01 (modal) which is the dark area behind the popup.