I'm brand new to jquery, and I need a little help with this simple accordion menu code:
$(document).ready(function(){ $("dd:not(:first)").hide(); $("dt a").click(function(){ $("dd:visible)").slideUp("slow"); $(this).parent().next().slideDown("slow"); return false; }); }); The html is like this: <dt><a href="/">Section</a></dt> <dd> <ul> <li><a href="url">Item</a></li> And so on... It works nicely, but I don't know how to make it so that when you click on a section title that is ALREADY open, it will close instead. At the moment, it will close and then slide open again. I'm sure there's a simple condition that will fix it, but I'm shooting in the dark at the moment and can't seem to do it. Any help much appreciated.