Created
March 2, 2013 10:23
-
-
Save thinkphp/5070420 to your computer and use it in GitHub Desktop.
Event Delegation on CUI Library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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