<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="JQuery/jquery-2.0.0.js" type="text/javascript"></script>
<script src="JQuery/jquery.cookie.js" type="text/javascript"></script>
</head>
<body>
<p id="pLastTime"></p>
<script type="text/javascript">
$(function () {
if ($.cookie("time")) {//刷新或加载页面后首先读取cookie判断里面是否含有需要的时间
$("#pLastTime").text($.cookie("time"));//有的话就写入页面
}
//无论有或没有,都将本次刷新的事件写入cookie
$.cookie("time", new Date().toLocaleTimeString(), { expires: 7, path: "/", secure: false });
});
</script>
</body>
</html>
cookie练习
最新推荐文章于 2024-04-27 16:07:06 发布