<div class="codetitle"> <span><a style="CURSOR: pointer" data="46513" class="copybut" id="copybut46513" onclick="doCopy('code46513')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code46513"> <br><!DOCTYPE html> <br><html> <br><머리> <br><title>cookies.html</title> <br><br><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <br><meta http-equiv="description" content="내 페이지입니다"> <br><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <br><br><style type="text/css"> <br>.txt{ <br>너비: 150px; <br>높이:20px; <br>테두리: 1px 파란색 단색; <br>테두리 반경:0.5em; <br>여백 하단: 5px; <br>왼쪽 여백: 5px; <br>} <br><br></style> <br><script type="text/javascript" src="../js/jquery-1.10.2.js"></script> <br><script type="text/javascript" src="../js/jquery.cookie.js"></script> <br><script type="text/javascript"> <br>$(function(){ <br><br><br>if($.cookie("name")){ <br>//取值如果存재则赋值 <br>$("#username" ).val($.cookie("이름")); <br><br>} <br><br><br>$("#mycookie").submit(function(){ <br><br> //如果选中了保存사용户name选项 <br>if($("#chkSave").is(":checked")){ <br><br>//设置Cookie值 <br>$.cookie(" name",$("#username").val(),{ <br>만료일: 7,//设置保存期限 <br>경로:"/"//设置保存的路径 <br><br>}) ; <br><br>}else{ <br><br>//销毁对象 <br>$.cookie("name",null,{ <br>path:"/" <br><br>}) ; <br>} <br><br>거짓 <br>}) <br><br>}); <br><br><br></script> <br></head> <br><본문> <br><form action="#" method="get" id="mycookie"> <br><br><div> <br>용도명:<br> <br><input id="username" name="username" type="text" class="txt"> <br></div> <br><div> <br>密码:<br> <br><input id="password" name="password" type="password" class="txt"> <br></div> <br><div> <br><input id="chkSave" type="checkbox">是否保存用户name <br></div> <br><div> <br><input id="cookBtn" class="btn" type="submit" value="提交"> <br></div> <br><br></form> <br></body> <br></html> <br> </div>