Can you make a jsFiddle that we can try?
Did you just fail to post the HTML that has class='leftpanel' and class='nav'?
You also don't have any class='children'. So, this will never find anything:
var child = jQuery(this).parent().find('.children');
Your class names make this very confusing to read! You should avoid using generic terms like 'parent', 'child' (or similar words) for class names, especially when they are the same as the names of jQuery functions. You should try to write code that is easy to read, not that makes a good dyslexia test!
Minor issue: why are you repeatedly writing "jQuery"? (I'll bet this is a Wordpress site, right? Why doesn't somebody write a tutorial for WP developers that doesn't sprinkle "jQuery" everywhere?!) If you have some other library that steals $, or have to work with multiple versions of jQuery (why? Oh.... WP, or some WP theme) you can at least still wrap your code in an self-executing function that makes it easier to read:
- (function($){
- // Your code here, now you can use $ and not overwrite
- // some global $
- var $stuff = $('.stuff');
- })(jQuery);
It's conventional, though, to pass more than just $, if you want to be super cautious.