0

I have a simple function that rotate images and works fine. But the problem is that after reload page is the first always default image, so rotate begin from start. I would like to have after reload page the same image as before reload and continue to rotate. I know that I have to use cookies but I don't know how. Is some simply way to solve it? Thanks advance.

The function of rotate:

    $.fn.rotate = function() {
    var container = $(this);
    var totale = container.find(\"div\").size();
    var current = 0;
    var i = setInterval(function() {
        if (current >= totale) current = 0;
        container.find(\"div\").filter(\":eq(\"+current+\")\").fadeIn(2000).end().not(\":eq(\"+current+\")\").fadeOut(2000);
        current++;
    }, 2000);
    return container;
   };
  })(jQuery);
Jaroslav Klimčík
  • 4,548
  • 12
  • 39
  • 58

1 Answers1

1

Look at this here: https://github.com/carhartl/jquery-cookie

You can set and load a cookie using jQuery.

bobek
  • 8,003
  • 8
  • 39
  • 75