Get attribute from dynamicly loaded element

Get attribute from dynamicly loaded element

Probably asked a thousand times before, but I really can't find the answer.

This is my code:

  1. $.fn.eepager = function(options) {
  2. var defaults = {
  3. holder: $('#more'),
  4. target: $('#more'),
  5. link: $('#readMore a'),
  6. };
  7. var options = $.extend(defaults, options);
  8. $('body').off("click").on("click", options.link,function(e) {
  9. e.preventDefault();
  10. var link = options.link.attr('href');
  11. $.get(link, function(data){ 
  12.  $(data).find("#more").appendTo(options.target);
  13.  $(".paglink").html($(data).find(".paglink").html());
  14. });
  15. });
  16. };

The code that's placed withing ".paglink" is a "next" button with another url every time it is loaded. However, every time a user clicks that button, the old href value is used (the one which was hardcoded when the page is loaded for the first time). The href from the dynamicly loaded button is ignored.

What am I doing wrong?

Thanks a lot!