Change window onload to work after pagination

I have the following JQuery which works on initial page load:

  $(window).on('load', function(){
    $('.details').hover(function() {
    $(this).find('.description').stop().animate({
      height: "toggle",
      opacity: "toggle"
    }, 200);
  });
});

Now that I have added pagination and filters to the page, the window onload obviously won’t work once any pagination or filters have been triggered. I understand that I need to create an additional function to ensure the above will still work, however I believe that there is something not write with my code, as when pagination is used, I am still getting no jquery. I am using the correct approach?

This is what I have so far:

 document.onreadystatechange = function(){
if (document.readyState === "complete") {
  $('.details').hover(function() {
    $(this).find('.description').stop().animate({
      height: "toggle",
      opacity: "toggle"
    }, 200);
  });
}
else {
   window.onload = function () {
    $('.details').hover(function() {
    $(this).find('.description').stop().animate({
      height: "toggle",
      opacity: "toggle"
    }, 200);
  });
   };
  };
 }

I am still learning.

30 thoughts on “Change window onload to work after pagination”

Leave a Comment