problem with toggle (shows and hides many times)

problem with toggle (shows and hides many times)

I made a toogle navigation and it doesn't work. when I click on a link in the menu, the toogle appears and disappears several times. I'm really new in jquery. Could you help please?

  1. <script type="text/javascript"> 
  2.       $(document).ready(function(){
  3.              $(".btn-open").click(function(){ 
  4.                   $("#panel").slideToggle("slow"); 
  5.             });
  6.             $(window).resize(function(){ 
  7.                   if ($(window).width() < 1024) { 
  8.                         $(".navigation li").click(function() { 
  9.                               $("#panel").slideToggle("slow"); 
  10.                         }); 
  11.                         $("#panel").val('Close').toggle(); 
  12.                   
  13.             }); 
  14.       }); 
  15. </script>