It means whether the element that triggered the event click
(event.target
) was the very document (document.documentElement
). That is, if you click anywhere empty on the page where there is no element of body
(div, a, input etc.), will satisfy the condition of if
.
operador de igualdade
por valor e tipo
↑
event.target === document.documentElement
↓ ↓
elemento que <html>...</html>
disparou o evento
Now, the same could be done only with document.onclick
instead of document.documentElement.onclick
. The difference is that the document
is an object that represents the whole document, while documentElement
is an object representing the tag html
page.
This way, if I create a modal (for example) and click out of it, this condition will be valid to remove the modal? interesting
– Everton Neri
No. You would have to use another code. Something like this answer: https://answall.com/a/375537/8063
– Sam