title: JQuery Cycle - Before callback parameters
body: <p>I can't seem to figure out how to use the parameters of the Before callback of Jquery Cycle.</p>
  
  <pre><code>jQuery('#slider_accueil').cycle({ 
      fx:     'fade',
      timeout: 5000,
      after: onAfter,
      before: onBefore,
      startingSlide: 0,
      next: '.next_btn_slider',
      prev: '.prev_btn_slider'
  });
  
  function onBefore(currSlideElement, nextSlideElement, options, forwardFlag){
      jQuery('.indicator').removeClass('current')
  }
  </code></pre>
  
  <p>I want to do something in the container of the next element, but nextSlideElement sends back loads of data, and nothing of it that I can relate to the next element in line (was looking for some kind of id or class, that I could not find)</p>
  
  <p>So here's the heart of the question: How to I target the next element being slided to with the onBefore function above?</p>
  
  <p>EDIT: Heres an image of the nextSlideElement put into the console via <code>console.dir(nextSlideElement)</code></p>
  
  <p><img src="https://i.stack.imgur.com/NJhzu.jpg" alt="enter image description here"></p>
  
  <p>EDIT 2: Here is the code, I'm trying to add a class to the thumbnail related to each slide (1 with 1, 2 with 2, etc.)</p>
  
  <pre><code>&lt;!--Slider sur l'accueil--&gt;
  &lt;div id="sliderAccueil"&gt;
  
      &lt;!--Contrôles du slider (next/previous)--&gt;
      &lt;div style="display:none;"&gt;&lt;/div&gt;
      &lt;img class="prev_btn_slider" src="http://www.x.com/wp-content/themes/Sandbox/images/slider_previous.png" alt="Image Précédente" /&gt;
      &lt;img class="next_btn_slider" src="http://www.x.com/wp-content/themes/Sandbox/images/slider_next.png" alt="Image Suivante" /&gt;
      &lt;div id="nav"&gt;&lt;/div&gt;
  
      &lt;!--Images du slider--&gt;                
      &lt;div id="slider_accueil"&gt;
  
  
          &lt;div style="width:778px; height:384px; overflow:hidden;"&gt;
              &lt;a href="http://www.x.com/"&gt;
  
                  &lt;!--Image--&gt;
                                              &lt;img src="http://www.x.com/wp-content/uploads/2011/09/slider1.jpg" alt="Assurer la Sécurité" /&gt;
  
                  &lt;!--Contenu rajouté--&gt;
                  &lt;div&gt;
                                                      &lt;div class="maintext"&gt;
                                                                                                              &lt;h2&gt;Assurer la Sécurité&lt;/h2&gt;
                                                                                                      &lt;p&gt;Assurer la Sécurité&lt;/p&gt;
                                                          &lt;/div&gt;
                      &lt;div class="link"&gt;
                          &lt;a href="http://www.x.com/"&gt;En savoir plus&lt;/a&gt;
                          &lt;a href="http://www.x.com/" class="call_slide"&gt;&lt;img src="http://www.x.com/wp-content/themes/Sandbox/images/call_slider.png" alt="En savoir plus" /&gt;&lt;/a&gt;
                      &lt;/div&gt;
                                                  &lt;/div&gt;
  
              &lt;/a&gt;
          &lt;/div&gt;
  
  
  
          &lt;div style="width:778px; height:384px; overflow:hidden;"&gt;
              &lt;a href="http://www.x.com/"&gt;
  
                  &lt;!--Image--&gt;
                                              &lt;img src="http://www.x.com/wp-content/uploads/2011/09/slider_item_bilan_travaux.jpg" alt="Bilan des travaux" /&gt;
  
                  &lt;!--Contenu rajouté--&gt;
                  &lt;div&gt;
                                                      &lt;div class="maintext"&gt;
                                                                                                              &lt;h2&gt;Special stuff&lt;/h2&gt;
                                                                                                      &lt;p&gt;Bilan des travaux&lt;/p&gt;
                                                          &lt;/div&gt;
                      &lt;div class="link"&gt;
                          &lt;a href="http://www.x.com/"&gt;En savoir plus&lt;/a&gt;
                          &lt;a href="http://www.x.com/" class="call_slide"&gt;&lt;img src="http://www.x.com/wp-content/themes/Sandbox/images/call_slider.png" alt="En savoir plus" /&gt;&lt;/a&gt;
                      &lt;/div&gt;
                                                  &lt;/div&gt;
  
              &lt;/a&gt;
          &lt;/div&gt;
  
  
  
          &lt;div style="width:778px; height:384px; overflow:hidden;"&gt;
              &lt;a href="http://www.x.com/"&gt;
  
                  &lt;!--Image--&gt;
                                              &lt;img src="http://www.x.com/wp-content/uploads/2011/09/slider_item_poutrelles.jpg" alt="Des travaux inusités à 300 pieds au-dessus de l’eau" /&gt;
  
                  &lt;!--Contenu rajouté--&gt;
                  &lt;div&gt;
                                                      &lt;div class="maintext"&gt;
                                                                                                              &lt;h2&gt;Travaux&lt;/h2&gt;
                                                                                                      &lt;p&gt;Des travaux inusités à 300 pieds au-dessus de l’eau&lt;/p&gt;
                                                          &lt;/div&gt;
                      &lt;div class="link"&gt;
                          &lt;a href="http://www.x.com/"&gt;En savoir plus&lt;/a&gt;
                          &lt;a href="http://www.x.com/" class="call_slide"&gt;&lt;img src="http://www.x.com/wp-content/themes/Sandbox/images/call_slider.png" alt="En savoir plus" /&gt;&lt;/a&gt;
                      &lt;/div&gt;
                                                  &lt;/div&gt;
  
              &lt;/a&gt;
          &lt;/div&gt;
  
  
  
          &lt;div style="width:778px; height:384px; overflow:hidden;"&gt;
              &lt;a href=""&gt;
  
                  &lt;!--Image--&gt;
                                              &lt;img src="http://www.x.com/wp-content/uploads/2011/10/slider-1961-05-05.jpg" alt="Photos d’archive" /&gt;
  
                  &lt;!--Contenu rajouté--&gt;
                  &lt;div&gt;
                                                      &lt;div class="maintext"&gt;
                                                                                                              &lt;h2 style="margin-bottom:0;"&gt;Photos d’archive&lt;/h2&gt;
                                                                                                  &lt;/div&gt;
                      &lt;div class="link"&gt;
                          &lt;a href=""&gt;En savoir plus&lt;/a&gt;
                          &lt;a href="" class="call_slide"&gt;&lt;img src="http://www.x.com/wp-content/themes/Sandbox/images/call_slider.png" alt="En savoir plus" /&gt;&lt;/a&gt;
                      &lt;/div&gt;
                                                  &lt;/div&gt;
  
              &lt;/a&gt;
          &lt;/div&gt;
  
  
  
          &lt;div style="width:778px; height:384px; overflow:hidden;"&gt;
              &lt;a href="http://www.x.com/"&gt;
  
                  &lt;!--Image--&gt;
                                              &lt;img src="http://www.x.com/wp-content/uploads/2011/09/slide_reseau_sociaux.jpg" alt="Branché sur les réseaux sociaux" /&gt;
  
                  &lt;!--Contenu rajouté--&gt;
                  &lt;div&gt;
                                                      &lt;div class="maintext"&gt;
                                                                                                              &lt;h2&gt;Réseaux Sociaux&lt;/h2&gt;
                                                                                                      &lt;p&gt;Branché sur les réseaux sociaux&lt;/p&gt;
                                                          &lt;/div&gt;
                      &lt;div class="link"&gt;
                          &lt;a href="http://www.x.com/"&gt;En savoir plus&lt;/a&gt;
                          &lt;a href="http://www.x.com/" class="call_slide"&gt;&lt;img src="http://www.x.com/wp-content/themes/Sandbox/images/call_slider.png" alt="En savoir plus" /&gt;&lt;/a&gt;
                      &lt;/div&gt;
                                                  &lt;/div&gt;
  
              &lt;/a&gt;
          &lt;/div&gt;
  
  
      &lt;/div&gt;&lt;!--#slider_accueil--&gt;
  
      &lt;!--Thumbnails contrôlant le slider--&gt;
      &lt;div id="thumbnails_slider_accueil"&gt;
  
          &lt;ul&gt;
  
  
              &lt;li id="li_thumb1"&gt;
                  &lt;a id="thumb1" class="thumb_slider_accueil"&gt;
                                                      &lt;div class="indicator"&gt;&lt;/div&gt;
                      &lt;div class="thumbnail" style="background:url(http://www.x.com/wp-content/uploads/2011/09/slider1-150x150.jpg) center center"&gt;
                          &lt;p&gt;Assurer la Sécurité&lt;/p&gt;
                      &lt;/div&gt;
                      &lt;div class="clear"&gt;&lt;/div&gt;
                                                  &lt;/a&gt;
              &lt;/li&gt;
  
  
              &lt;li id="li_thumb2"&gt;
                  &lt;a id="thumb2" class="thumb_slider_accueil"&gt;
                                                      &lt;div class="indicator"&gt;&lt;/div&gt;
                      &lt;div class="thumbnail" style="background:url(http://www.x.com/wp-content/uploads/2011/09/slider_item_bilan_travaux-150x150.jpg) center center"&gt;
                          &lt;p&gt;Bilan des travaux&lt;/p&gt;
                      &lt;/div&gt;
                      &lt;div class="clear"&gt;&lt;/div&gt;
                                                  &lt;/a&gt;
              &lt;/li&gt;
  
  
              &lt;li id="li_thumb3"&gt;
                  &lt;a id="thumb3" class="thumb_slider_accueil"&gt;
                                                      &lt;div class="indicator"&gt;&lt;/div&gt;
                      &lt;div class="thumbnail" style="background:url(http://www.x.com/wp-content/uploads/2011/09/slider_item_poutrelles-150x150.jpg) center center"&gt;
                          &lt;p&gt;Des travaux inusités à 300 pieds au-dessus de l’eau&lt;/p&gt;
                      &lt;/div&gt;
                      &lt;div class="clear"&gt;&lt;/div&gt;
                                                  &lt;/a&gt;
              &lt;/li&gt;
  
  
              &lt;li id="li_thumb4"&gt;
                  &lt;a id="thumb4" class="thumb_slider_accueil"&gt;
                                                      &lt;div class="indicator"&gt;&lt;/div&gt;
                      &lt;div class="thumbnail" style="background:url(http://www.x.com/wp-content/uploads/2011/10/slider-1961-05-05-150x150.jpg) center center"&gt;
                          &lt;p&gt;Photos d’archive&lt;/p&gt;
                      &lt;/div&gt;
                      &lt;div class="clear"&gt;&lt;/div&gt;
                                                  &lt;/a&gt;
              &lt;/li&gt;
  
  
              &lt;li id="li_thumb5"&gt;
                  &lt;a id="thumb5" class="thumb_slider_accueil"&gt;
                                                      &lt;div class="indicator"&gt;&lt;/div&gt;
                      &lt;div class="thumbnail" style="background:url(http://www.x.com/wp-content/uploads/2011/09/slide_reseau_sociaux-150x150.jpg) center center"&gt;
                          &lt;p&gt;Branché sur les réseaux sociaux&lt;/p&gt;
                      &lt;/div&gt;
                      &lt;div class="clear"&gt;&lt;/div&gt;
                                                  &lt;/a&gt;
              &lt;/li&gt;
                                  &lt;/ul&gt;
  
      &lt;/div&gt;&lt;!--#thumbnails_slider_accueil--&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;!--#sliderAccueil--&gt;
  </code></pre>
  
  <p>A part of it is in french, but the code is the same thing over languages</p>