Cookies en Outbook

Esta web utiliza cookies propias para ofrecer una mejor experiencia. Al navegar, aceptas dichas cookies.
  • Más información acerca de las cookies

Outbook

UI-Dev & more

Javascript: Click outside element

Simply function to detect click event outside desired element:

document.onclick = function (e) {
 e = e || event
 var target = e.target || e.srcElement
 var element = document.getElementById('id_element');
 do {
  if (element == target) {
   // When clicked inside element, does nothing
   return;
  }
  target = target.parentNode;
 } while (target)
 // When clicked outside element, makes an action.
 element.style.display = 'none';
}

Read at Closing a floating div layer Webdeveloper.com.

Publicado

Categorías: