title: My dropdown menu not working when I updating page with Ajax
body: <p>I have a sidebar in body and also I have a content section in body. You can think</p>
  
  <pre><code>&lt;aside class="sidebar-left-collapse"&gt;
  
      &lt;a href="#" class="company-logo"&gt;Logo&lt;/a&gt;
  
      &lt;div class="sidebar-links"&gt;
  
          &lt;div class="link-yellow selected"&gt;
              &lt;a href="katalog/camgurubu.html"&gt;
                  KAPAK
              &lt;/a&gt;
          &lt;/div&gt;
  
          &lt;div class="link-blue"&gt;
              &lt;a href="katalog/cam2.html"&gt;
                  CAM GURUBU
              &lt;/a&gt;
              &lt;ul class="sub-links"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Paşabahçe&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
  
          &lt;div class="link-red"&gt;
              &lt;a href="#"&gt;
                  PORSELEN GURUBU
              &lt;/a&gt;
              &lt;ul class="sub-links"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;KÜTAHYA PORSELEN&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;BONNA PORSELEN&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
  
          &lt;div class="link-yellow"&gt;
              &lt;a href="#"&gt;
                  ÇATAL/KAŞIK/BIÇAK
              &lt;/a&gt;
              &lt;ul class="sub-links"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;ARYILDIZ ÇATAL/KAŞIK/BIÇAK&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;ŞEHZADE ÇATAL/KAŞIK/BIÇAK&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;ALMOND ÇATAL/KAŞIK/BIÇAK&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;NARİN ÇATAL/KAŞIK/BIÇAK&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
  
          &lt;div class="link-green"&gt;
  
              &lt;a href="#"&gt;
                  MUTFAK SET ÜSTÜ MALZEMELERİ
              &lt;/a&gt;
  
              &lt;ul class="sub-links"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;DOLLY PLASTİK ÜRÜNLER&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;PİRGE BIÇAKLARI&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;VİCTORİNOX BIÇAKLARI&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;İTHAL MALZEME SET ÜSTÜ GRUBU&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;BORA SAKLAMA KABI VE DİĞER MALZEMELER&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;TÜRKAY POLİETİLEN GRUPLARI&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;CAMBRO ÜRÜNLERİ&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;PLASTİK,POLİKARBON MALZEMELER&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;KÜLSAN (THERMOSET MALZEMELER)&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;NARİN SET ÜSTÜ MALZEMELERİ&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;ARYILDIZ SET ÜSTÜ MALZEMELER&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;ALTINBAŞAK TEFLON TAVALAR,FAJİTA GRUPLARI, SET ÜSTÜ ÜRÜNLER&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;TEL KEVGİR, SÜZGEÇ, ÇIRPICI ÜRÜNLER GURUBU&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;KEPÇE, KEVGİR, SPATULA, MAŞA  SERVİS GRUPLARI&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;TRİBECA ÜRÜN GRUPLARI&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;ALKAN-ZİCCO ÜRÜN GRUPLARI&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;ÇÖP KOVALARI&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;TENCERELER&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;KAÇAROLA/KÜVETLER&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;DERİ ÜRÜNLERİ VE MENÜLER&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;PİZZA TAVALARI&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;FIRIN KÜREKLERİ&lt;/a&gt;&lt;/li&gt;
  
              &lt;/ul&gt;
  
          &lt;/div&gt;
          &lt;div class="link-green"&gt;
  
              &lt;a href="#"&gt;
                  AÇIK BÜFE EKİPMANLARI
              &lt;/a&gt;
  
              &lt;ul class="sub-links"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;İTHAL AÇIK BÜFE MALZEMELERİ&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;CHAFİNG DISH&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;BORA AÇIK BÜFE ÜRÜNLER&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;ALKAN-ZİCCO AÇIK BÜFE ÜRÜN GRUPLARI&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;GÜREN METAL AÇIK BÜFE ÜRÜNLERİ&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;KÜLSAN AÇIK BÜFE ÜRÜNLER&lt;/a&gt;&lt;/li&gt;
  
              &lt;/ul&gt;
  
          &lt;/div&gt;
          &lt;div class="link-green"&gt;
  
              &lt;a href="#"&gt;
                  PASTAHANE EKİPMANLARI
              &lt;/a&gt;
  
              &lt;ul class="sub-links"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;ARYILDIZ PASTAHANE ÜRÜNLERİ&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;PASTA,KEK KALIPLARI ALÜMİNYUM MALZEMELER&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
  
          &lt;/div&gt;
          &lt;div class="link-green"&gt;
  
              &lt;a href="#"&gt;
                  GENEL MALZEME GRUBU
              &lt;/a&gt;
  
              &lt;ul class="sub-links"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;PLASTİK TAŞIMA EKİPMANLARI VE AKSESUARLARI&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;KAHVE MAKİNALARI &lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;AHŞAP SERVİS EKİPMANLARI&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
  
          &lt;/div&gt;
          &lt;div class="link-green"&gt;
  
              &lt;a href="#"&gt;
                  CİHAZLAR
              &lt;/a&gt;
  
              &lt;ul class="sub-links"&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              HAZIRLIK
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                  &lt;li&gt;&lt;a href="#"&gt; Arda &lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt; Zaman &lt;/a&gt;&lt;/li&gt;
                              &lt;li&gt;&lt;a href="#"&gt; Deneme&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              KAFETERYA CİHAZLARI
                          &lt;/a&gt;
              &lt;ul class="sub-links"&gt;
                  &lt;li&gt;&lt;a href="#"&gt; Arda &lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt; Zaman &lt;/a&gt;&lt;/li&gt;
                              &lt;li&gt;&lt;a href="#"&gt; Deneme&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              BULAŞIKHANE
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              PİŞİRME GURUBU 600 SERİ
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              PİŞİRME GURUBU 700 SERİ
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              PİŞİRME GURUBU 900 SERİ
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              KONVEKSİYONLU FIRINLAR
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              SOĞUTMA EKİPMANLARI
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              TEŞHİR ÜRÜNLERİ
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              RAF ÜRÜNLERİ
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              TEZGAH/DAVLUMBAZ/YER SÜZGEÇLERİ
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              ÇAMAŞIRHANE GRUBU
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;div class="link-green"&gt;
                          &lt;a href="#"&gt;
                              İTHAL ÜRÜNLER
                          &lt;/a&gt;
                          &lt;ul class="sub-links"&gt;
                              &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
  
                      &lt;/div&gt;
                  &lt;/li&gt;
              &lt;/ul&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
  
  &lt;/aside&gt;
  
  &lt;div class="main-content"&gt;
  
      &lt;div class="menu"&gt;
  
          &lt;section id="content"&gt;
  
          &lt;/section&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>When I update content section with ajax dropdown menu doesn't work. I think the problem is, menu selected class unchanged because ajax refresing page.</p>
  
  <pre><code>        var links = $('.sidebar-links &gt; div');
      var links2 = $('.sidebar-links &gt; div &gt; ul.sub-links &gt; li &gt; div');
  
      links.on('click', function () {
          links.removeClass('selected');
          $(this).addClass('selected');
      });
  
      links2.on('click', function () {
  
          links2.removeClass('selected');
          $(this).addClass('selected').show();
  
      });
  
      $('.sidebar-links div a').on('click' ,function(){
          var yol = $(this).attr('href');
          $(this).attr("href", "#");
  
          $.ajax({
                    async: true,
                    type: "GET",
                    url: yol,
                    success: function (html) {
                        $("#content").html(html);
                    }
                });
      });
  </code></pre>