jq操作cookie
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title></title> <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script src="../Scripts/jquery.cookies.2.2.0.min.js" type="text/javascript"></script> <script src="../Scripts/jquery.cookie.js" type="text/javascript"></script> <!--记得添加jquery.cookie.js--> <script type ="text/javascript" > $(function () { // alert($.cookie("用户名")); // $($.cookie("用户名", "tom")); //给cookie赋值 }); $(function () { if ($.cookie("用户")) {//判断cookie是否为空 $("#txtCookie").val($.cookie("用户")); } $("#btnCok").click(function () { $.cookie("用户", $("#txtCookie").val()); }); }); </script> </head> <body> <input type ="text" id ="txtCookie" /> <input type ="button" id ="btnCok" value ="确定"/> </body> </html>