$(function () { $(".tabsli").click(function () { //keep last active tab, to avoid once user expand an email the page will reload, then "new email" tab will be acived var active = $("#tabs").tabs("option", "active"); setCookie("task_email_active_tab", active); //save current active tab‘s index to cookie //alert(active); }); var lastActive = getCookie("task_email_active_tab"); //get current active tab‘s index from cookie if (lastActive=="" || lastActive==null) { lastActive = 0; } //alert(lastActive); $("#tabs").tabs({ active: lastActive }); });