在cookie上保存当前div id

时间:2016-11-01 11:29:15

标签: javascript jquery cookies

我有这段代码:

$(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    
});

如何修改它以保存用户在COOKIE上查看的最后一个DIV? 我搜索了很久,我找不到,请..

1 个答案:

答案 0 :(得分: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);
}




喜欢那个?