Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #20903

Re: Enhancing typical CSS drop menu with onclick event

From Tuxedo <tuxedo@mailinator.com>
Newsgroups comp.lang.javascript
Subject Re: Enhancing typical CSS drop menu with onclick event
Date 2013-08-09 21:23 +0200
Organization albasani.net
Message-ID <ku3fjj$pso$1@news.albasani.net> (permalink)
References <ktonod$ei8$1@news.albasani.net> <19fdmc1ur4uoq$.11i5vm93mk195$.dlg@40tude.net> <ktr27r$nsh$1@news.albasani.net> <169h2xu4o50sk.ejf3hto84v6q.dlg@40tude.net>

Show all headers | View raw


JJ wrote:

> On Tue, 6 Aug 2013 16:46:18 +0200, Tuxedo wrote:

[...]

> 
> I forgot about that, sorry. This one's better.

Many thanks for posting the below version. It works perfectly!

Tuxedo

> 
> (function() {
>   var last = null;
>   function closeLast(now) {
>     if (last) {
>       last.style.left = "";
>     }
>     last = now;
>   }
>   function clicked(ev) {
>     var ev = ev || event;
>     var node = ev.target || ev.srcElement;
>     if ((node.tagName==="A") && (node.parentNode.className==="navmenu")) {
>       var dropdown = node.parentNode.querySelector(".dropdown");
>       if (dropdown !== last) {
>         dropdown.style.left = "auto";
>         closeLast(dropdown);
>       } else {
>         closeLast(null);
>       }
>       if (ev.preventDefault) {
>         ev.preventDefault();
>       } else {
>         ev.returnValue = false;
>       }
>     } else {
>       closeLast(null);
>     }
>   }
>   if (document.addEventListener) {
>     document.addEventListener("click", clicked, false);
>   } else {
>     document.attachEvent("onclick", clicked);
>   }
> })();

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Enhancing typical CSS drop menu with onclick event Tuxedo <tuxedo@mailinator.com> - 2013-08-05 19:35 +0200
  Re: Enhancing typical CSS drop menu with onclick event JJ <duh@nah.meh> - 2013-08-06 15:59 +0700
    Re: Enhancing typical CSS drop menu with onclick event Tuxedo <tuxedo@mailinator.com> - 2013-08-06 16:46 +0200
      Re: Enhancing typical CSS drop menu with onclick event JJ <duh@nah.meh> - 2013-08-07 03:23 +0700
        Re: Enhancing typical CSS drop menu with onclick event Tuxedo <tuxedo@mailinator.com> - 2013-08-09 21:23 +0200

csiph-web