The following script contains comments explaining which jQuery actions are being performed.

view plaincopy to clipboardprint?

1. $(document).ready(function(){
2.
3. $("ul.subnav").parent().append(""); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)
4.
5. $("ul.topnav li span").click(function() { //When trigger is clicked...
6.
7. //Following events are applied to the subnav itself (moving subnav up and down)
8. $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
9.
10. $(this).parent().hover(function() {
11. }, function(){
12. $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
13. });
14.
15. //Following events are applied to the trigger (Hover events for the trigger)
16. }).hover(function() {
17. $(this).addClass("subhover"); //On hover over, add class "subhover"
18. }, function(){ //On Hover Out
19. $(this).removeClass("subhover"); //On hover out, remove class "subhover"
20. });
21.
22. });