I don't think you should be using a list to do this. So i've changed the code structure to suit and given the old 'li' a class name 'item'. I also pass through a data attribute to help identify the currently selected item.
The way it works is that if the current selected item is clicked, the details div will hide, otherwise it will be revealed. If it is already open but a different item is clicked, it will remain open.
https://jsfiddle.net/z7phyztx/16/
<script>
$(".mydiv .item").click(function() {
$this = $(this);
if ($(this).hasClass('active')){
$('.item').removeClass('active');
$(".detail").hide("slow", function() {
// Animation complete.
});
return false;
}
$('.item').removeClass('active');
$(this).addClass('active');
$(".detail").show("slow", function() {
// Animation complete.
$(this).attr('data-position', $this.data('position'));
});
});
</script>