一段关于读取cookie的jquery的写法 30
大家好,我想写个jquery句子关于提取cookie中的一个参数。首先我用toggle做了个伸缩树状菜单,有4个菜单。上来默认的第一个是打开的,我用$(".cat-ite...
大家好,我想写个jquery句子关于提取cookie中的一个参数。首先我用toggle做了个伸缩树状菜单,有4个菜单。上来默认的第一个是打开的,我用$(".cat-item-5 .toggle").trigger("click"); 然后用户打开了第二个菜单点了里面的内容,页面刷新后默认打开的菜单变第二个了。 我想写个类似于以下的句子
a = $.cookie('xxx');
if (a)
$(".a .toggle").trigger("click");
else
$(".cat-item-5 .toggle").trigger("click");
具体语法不是很清楚,然后菜单的格式为
<ul class="accordion">
<li class="cat-item cat-item-3"><a class="toggle" 。。。。。。
请大大们帮我修改下吧,万分感谢。。。。 展开
a = $.cookie('xxx');
if (a)
$(".a .toggle").trigger("click");
else
$(".cat-item-5 .toggle").trigger("click");
具体语法不是很清楚,然后菜单的格式为
<ul class="accordion">
<li class="cat-item cat-item-3"><a class="toggle" 。。。。。。
请大大们帮我修改下吧,万分感谢。。。。 展开
1个回答
展开全部
登记,可以理解为添加一个cookie
那么相应的就会有“SetCookies”、“AddCookies”、“DeleteCookies”、“SearchCookies”、“GetCookies”、“ChkCookies”等等;
你可以尝试一下,用程序操作Cookies;
public static void ShowCookies()
{
Int16 i;
HttpCookieCollection cookies = System.Web.HttpContext.Current.Request.Cookies;
for (i = 0; i < cookies.Count; i++)
{
HttpCookie cookie = cookies.Get(i);
System.Web.HttpContext.Current.Response.Write("Cookie名称: " + cookie.Name + "<br/>");
System.Web.HttpContext.Current.Response.Write("值=: " + cookie.Value + "<br/>");
System.Web.HttpContext.Current.Response.Write("Expires期限: " + cookie.Expires.ToString() + "<br/>");
System.Web.HttpContext.Current.Response.Write("<hr/>");
// System.Web.HttpContext.Current.Response.Write ("Domain网域:" + cookie.Domain + "<br/>");
// System.Web.HttpContext.Current.Response.Write ("Path路径:" + cookie.Path + "<br/>");
//System.Web.HttpContext.Current.Response.Write ("Secure保密:" + cookie.Secure + "<br/>");
}
System.Web.HttpContext.Current.Response.Write("共有 " + cookies.Count + " 个Cookie<br/>");
}
public static void DeleteAllCookies()
{
Int16 i;
HttpCookieCollection cookies = System.Web.HttpContext.Current.Request.Cookies;
for (i = 0; i < cookies.Count; i++)
{
HttpCookie cookie = cookies.Get(i);
cookie.Value = "";
cookie.Expires = DateTime.Now.AddDays(-365);
System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
}
System.Web.HttpContext.Current.Response.Write("共有 " + cookies.Count + " 个Cookie被删除<br/>");
/* cookies.Clear(); */
}
public static void ClearAllCookies()
{
Int16 i;
HttpCookieCollection cookies = System.Web.HttpContext.Current.Request.Cookies;
for (i = 0; i < cookies.Count; i++)
{
HttpCookie cookie = cookies.Get(i);
cookie.Value = "";
System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
}
System.Web.HttpContext.Current.Response.Write("共有 " + cookies.Count + " 个Cookie被清空<br/>");
}
那么相应的就会有“SetCookies”、“AddCookies”、“DeleteCookies”、“SearchCookies”、“GetCookies”、“ChkCookies”等等;
你可以尝试一下,用程序操作Cookies;
public static void ShowCookies()
{
Int16 i;
HttpCookieCollection cookies = System.Web.HttpContext.Current.Request.Cookies;
for (i = 0; i < cookies.Count; i++)
{
HttpCookie cookie = cookies.Get(i);
System.Web.HttpContext.Current.Response.Write("Cookie名称: " + cookie.Name + "<br/>");
System.Web.HttpContext.Current.Response.Write("值=: " + cookie.Value + "<br/>");
System.Web.HttpContext.Current.Response.Write("Expires期限: " + cookie.Expires.ToString() + "<br/>");
System.Web.HttpContext.Current.Response.Write("<hr/>");
// System.Web.HttpContext.Current.Response.Write ("Domain网域:" + cookie.Domain + "<br/>");
// System.Web.HttpContext.Current.Response.Write ("Path路径:" + cookie.Path + "<br/>");
//System.Web.HttpContext.Current.Response.Write ("Secure保密:" + cookie.Secure + "<br/>");
}
System.Web.HttpContext.Current.Response.Write("共有 " + cookies.Count + " 个Cookie<br/>");
}
public static void DeleteAllCookies()
{
Int16 i;
HttpCookieCollection cookies = System.Web.HttpContext.Current.Request.Cookies;
for (i = 0; i < cookies.Count; i++)
{
HttpCookie cookie = cookies.Get(i);
cookie.Value = "";
cookie.Expires = DateTime.Now.AddDays(-365);
System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
}
System.Web.HttpContext.Current.Response.Write("共有 " + cookies.Count + " 个Cookie被删除<br/>");
/* cookies.Clear(); */
}
public static void ClearAllCookies()
{
Int16 i;
HttpCookieCollection cookies = System.Web.HttpContext.Current.Request.Cookies;
for (i = 0; i < cookies.Count; i++)
{
HttpCookie cookie = cookies.Get(i);
cookie.Value = "";
System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
}
System.Web.HttpContext.Current.Response.Write("共有 " + cookies.Count + " 个Cookie被清空<br/>");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询