title: Fancybox callback - click function
body: <p>I want to add a pagination inside the fancybox. But with the clickevent which is described here: <a href="https://stackoverflow.com/questions/2920048/adding-button-click-event-when-fancybox-popup-opened">Adding button click event when Fancybox popup opened</a> nothing is working.</p>
  
  <p>here is my js code:</p>
  
  <pre><code>onComplete: function(){ 
  
        $(".fancybox-nav").click(function(){  
  
            console.log("it works");
  
            var $that = $(this);
            var nav = $that.attr('class');
            var number = $('.fancybox-inner').find('.currentpage').text()
            var intnumber = parseInt(number);
            if (intnumber &gt;= 1 &amp;&amp; intnumber &lt;= $('.item').length &amp;&amp; nav == 'fancybox-nav fancybox-next') {       
                                      intnumber += 1;
                              }
                              else if(intnumber &gt; 1){
                                  intnumber -= 1;
                              };   
                              var stringnumber = String(intnumber);
                              $('.fancybox-inner')
                                  .find('.currentpage')
                                      .replaceWith('&lt;span class="currentpage"&gt;' + stringnumber + '&lt;/span&gt;');    
                          });
  
                      },
  </code></pre>
  
  <p>How can I implement a click function inside my fancybox?</p>