I am working on chrome extension for facebook. If you use facebook, you know that when you scroll down to the bottom of the news feed/timeline/profile it shows more posts. The extension actually adds a button beside the "like" button. So I need to check if there are more posts to add that button to.
Right now to check if the page has been modified, I use setInterval(function(){},2000).
I want to run a function when the user clicks the button. But this function doesn't work if I put it outside (or even inside) setInterval() – The Koder just now edit 
How can I check if the webpage has been modified WITHOUT using a loop?
Example:
$(document).ready(function(){
    window.setInterval(function(){
          $(".UIActionLinks").find(".dot").css('display','none');
          $(".UIActionLinks").find(".taheles_link").css('display','none');
          $(".miniActionList").find(".dot").css('display','none');
          $(".miniActionList").find(".taheles_link").css('display','none');
              //only this function doesn't work:
          $(".taheles_link").click(function(){
            $(".taheles_default_message").hide();
            $(".taheles_saving_message").show();
          });
               //end
          $(".like_link").after('<span class="dot"> · </span><button class="taheles_link stat_elem as_link" title="תגיד תכל´ס" type="submit" name="taheles" onclick="apply_taheles()" data-ft="{"tn":">","type":22}"><span class="taheles_default_message">תכל´ס</span><span class="taheles_saving_message">לא תכלס</span></button>');
          $(".taheles_saving_message").hide();
    }, 2000);
});
In the future, this extension will use AJAX, so setInterval() can make even more problems for me.
 
     
     
     
    