Well, to solve the problem of repetition, use bind, so...(this may not be verbatim) function doit(event) { $(event.data.var1).siblings('li.navSel').removeClass('navSel'); $(event.data.var2).slideFadeToggle('normal'); $(this).toggleClass('navSel'); $(event.data.var2).siblings('div:visible').slideUp('fast'); return false; }); $(....).bind('click', {var1:'id1', var2:'id2'} doit);
you could probably even make a generic function and do a string replace... this.id.replace('nav', 'links') but that doesn't look too clean... In terms of finding 'partial' matches, you can use the attribute selector functions (look documentation:selectors), these are things like [EMAIL PROTECTED] not sure what you mean by 'not in use' but don't forget you can store values on dom nodes (var el = document.getElementbyId('somenode'); el.inuse = 'true';) or you can use something like a 'selected' class, and hasClass().