jQuery操作cookie
<html>
<head>
<title>Cookie测试</title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Scripts/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
if ($.cookie("content")) {
$("#txtInput").val($.cookie("content"));
}
// 保存1天。若不加expires这个属性,那么浏览器关闭后该cookie就会被清除
$('#btn').click(function () {
var txt = $("#txtInput").val();
$.cookie("content", txt, {expires:1});
});
});
</script>
</head>
<body>
<input id="txtInput" type="text" />
<input id="btn" type="button" value="查询" />
</body>
</html>
摘自 IT胖子的专栏
补充:web前端 , JavaScript ,