html 代码:
![](https://images2015.cnblogs.com/blog/625350/201510/625350-20151027103039825-1531335181.png)
$(function(){ $('ul.g-dropdown-menu li a').each(function(){ $(this).click(function(){ //$.cookie('areaId', '', { expires: 1 }); // 存储一个带7天期限的 cookie $.cookie('areaId', '1', { expires: 7 }); var cityid=$(this).attr("id"); cityid=cityid.substring(cityid.indexOf('_')+1); if(cityid==1){ $.cookie('areaId', '1', { expires: 7 }); console.log($.cookie('areaId')); } // var link = $(this).attr("href"); // windows.location.href = link; }); }); }) </script>