jQuery中cookie外掛如何使用
通過cookie外掛可以很便利的儲存使用者的頁面瀏覽記錄,在使用者選擇保護的情況下,還可以儲存使用者的情況
第一步
引入檔案,下載外掛: http://plugins.jquery.com/cookie/
第二步
<script type="text/javascript" src="js/jquery.cookie.js"></script>
第三步
如下例,html寫入你需要使用的輸入框
<div class="banner-bottom2">
<div class="bnr-one">
<div class="bnr-right">
<input class="dat" id="Rname" name="user" type="text" placeholder="暱稱">
<span class="error_news"></span>
</div>
</div>
<div class="bnr-one">
<div class="bnr-right">
<input class="dat" id="phoneNum" name="num" type="text" placeholder="手機號碼">
<span class="error_news"></span>
</div>
</div>
<div class="bnr-one">
<div class="bnr-right">
<input class="dat" id="Repass" name="password" type="password" placeholder="輸入密碼(6~9個字元)">
<span class="error_news"></span>
</div>
</div>
<div class="bnr-one">
<div class="bnr-right">
<input class="dat" id="Rnpass" name="confirm_password" type="password" placeholder="確認密碼">
<span class="error_news"></span>
</div>
</div>
<div class="bnr-btn">
<form>
<input type="submit" id="Rsbt" value="註冊" class="btn">
</form>
</div>
</div>
</div>
</div>
</div>
第四步
如下例,js檔案寫入使用cookie外掛
var again=0;
if($.cookie("username")){
$("#username").val($.cookies("username"))
}
$("#sbtUser").submit(function(){
if($("#save").attr("checked")){
$.cookie("username",$("username").val(),{
path:"/",expires:7
})
}
else{
$.cookie("username",null,{
path:"/"
})
}
return false;
})
第五步
點選submit提交按鈕即可儲存
相關文章
- 操作cookie外掛jquery.cookie用法CookiejQuery
- cookie外掛-jquery.cookie.js介紹CookiejQueryJS
- jquery.cookie外掛使用簡單介紹jQueryCookie
- 手寫jquery.cookie外掛jQueryCookie
- jquery操作cookie外掛程式碼分享jQueryCookie
- jQuery實現的cookie操作外掛jQueryCookie
- jQuery外掛:jqGrid使用(二)jQuery
- jQuery外掛:jqGrid使用(一)jQuery
- jQuery外掛jQuery
- jQuery如何製作自定義外掛jQuery
- 如何編寫一個Jquery外掛jQuery
- jquery 外掛站jQuery
- jQuery的Cookie使用jQueryCookie
- Headshot外掛如何使用?Headshot外掛使用教程
- jQuery中的工具與外掛個人分享jQuery
- JQuery模板外掛-jquery.tmpljQuery
- javascript操作cookie簡單外掛JavaScriptCookie
- jQuery的外掛列表jQuery
- JQuery蜂巢圖外掛jQuery
- jQuery外掛推薦jQuery
- jquery分頁外掛jQuery
- jquery外掛寫法jQuery
- 20151224jquery學習筆記---cookie外掛jQuery筆記Cookie
- jQuery表單外掛jQuery.formjQueryORM
- jQuery上傳外掛Uploadify使用詳解jQuery
- jQuery擴充套件外掛jQuery套件
- jQuery外掛擴充套件jQuery套件
- jquery日曆外掛SimpleCalendarjQuery
- jQuery外掛開發模式jQuery模式
- jquery--uploadify 外掛jQuery
- 240個jquery外掛(轉)jQuery
- jQuery layout 外掛屬性jQuery
- 200個jquery外掛jQuery
- 常用jquery外掛資料jQuery
- jquery外掛開發方法jQuery
- jquery外掛合集之分頁外掛[表單和表格]jQuery
- 不定義 jQuery 外掛,不要說會 jQueryjQuery
- jQuery外掛Tmpl使用方法簡單介紹jQuery