There is a convenient shorthand in jQuery: .slideToggle()
The selected element will be displayed if it's currently not, and vica-versa.
The other important part is, that you can just use $(this) in the event handler. It is the element which the event is handled on.
Also .children() is a tree traversal function. it means it's results will be selected relative to the selected elements it was called on. So $('#example').children('a') will select all links directly under the example element, so no $('#example').children('#example a') needed.
I have wrapped the code up for you:
$(document).ready(function() {
$('#navigation ul li').click(function(e) {
e.stopPropagation();
$(this).children('ul').slideToggle(400);
});
});
Or if you prefer to have 1 event handler and bubbling:
$(function() {
$('#navigation').on('click', 'li', function(e) {
e.stopPropagation();
$(this).children('ul').slideToggle(400);
});
});
Of course these two only work if the <ul> you toggle is the direct child of the <li> you fire the click event on.
EDIT:
As @thebreiflabb mentioned in the comments, because of event bubbling the click event will be fired on every parent of the clicked element by default.
If any of the parents also match the selector, the same event handler will be called on them.
e.stopPropagation() tells, that the event is handled here and it does not need to fire on parent elements.
To see the difference click on "Subitem 2" under "Item 4" in both of these fiddles:
With stopping propagation.
Without stopping propagation.
As you can see, without stopPropagation() "Item 4" also closes.