0

I have this code:

$(function games() {
  // Different timeouts for each div
  var times = [4000, 5000, 5000, 8000, 8000];
  var counter = 0;
  divs = $('#tuk1, #tuk2, #tuk3, #tuk4, #tuk5');

  function showDiv() {
    // hide all divs, filter current index, and fadeIn
    divs.hide().eq(counter).fadeIn(0);
    // set time out duration from array of times 
    setTimeout(showDiv, times[counter]);
    // cycle the counter     
    counter = (counter + 1) % divs.length;
  };
  showDiv(); // show first div    
});

How could I modify it to save the last DIV viewed by the user on a COOKIE? I searched for a long time, I do not find, please..

yceruto
  • 9,230
  • 5
  • 38
  • 65
clicdessu
  • 1
  • 1
  • 2
    All you need to do is store the current `counter` in a cookie, right? In which case [this question](http://stackoverflow.com/questions/14573223/set-cookie-and-get-cookie-with-javascript) contains all you need – Rory McCrossan Nov 01 '16 at 11:31
  • @Rory McCrossan Hello, thanks for your reply. I check this question but i dont undertsand :/ – clicdessu Nov 01 '16 at 11:37

1 Answers1

0

function cssLayout() {
    document.getElementById("tuk").href = this.value;
}


function setCookie(){
    var date = new Date("Februari 10, 2013");
    var dateString = date.toGMTString();
    var cookieString = "Css=document.getElementById("tuk").href" + dateString;
    document.cookie = cookieString;
}

function getCookie(){
    alert(document.cookie);
}

Like that ?

clicdessu
  • 1
  • 1