Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created March 2, 2013 10:23
Show Gist options
  • Select an option

  • Save thinkphp/5070420 to your computer and use it in GitHub Desktop.

Select an option

Save thinkphp/5070420 to your computer and use it in GitHub Desktop.
Event Delegation on CUI Library
var delegate = cui.event.delegate,
dom = cui.dom,
ready = cui.ready;
ready(function(){
delegate(dom.select("#menu"), 'li a', 'click', function( e ){
if(window.console) console.log(e.target)
var ul = e.target.parentNode.querySelector("ul")
if(ul.style.display == "none") {
ul.css("display: block")
} else {
ul.css("display: none")
}
}, false);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment