Remember which tab was active after refresh

前端 未结 17 2214
眼角桃花
眼角桃花 2020-11-27 04:43

I\'m using jquery tabs on a web page and when the page is refreshed it loses what ever tab I had been on and goes back to the first tab.

Has anyone come across this

17条回答
  •  暖寄归人
    2020-11-27 05:26

    Include the jquery cookies plugin :

    
    

    declare a cookie name inside $.function({.. or document.ready as

    var cookieName = "mycookie";
    
    $("#tabs").tabs({
        selected : ($.cookies.get(cookieName) || 0),
        select : function(e, ui) {
            $.cookies.set(cookieName, ui.index);
        }
            });
    

提交回复
热议问题