u JS .delegate() Event Delegation


$.ready(function() {

    $("#menu").delegate("li a", 'click', function(e) {

          var ul = this.parentNode.querySelectorAll('ul')[0]

          if(ul.style.display == '' || ul.style.display == 'block') {

             $(ul).css("display: none") 

          } else if(ul.style.display == 'none') {

             $(ul).css("display: block") 
          }
    })
})